I have a difficult time with getting the programs started. I read the book but I am not getting anywhere. There just is not enough examples to help me.

The book we are using for CSC 135 is called Java Software Solutions by Lewis & Loftus. We are starting on Chapter 5 Conditional and Loops.

Can you help me.

thanks

Dani AI

Generated

If starting is the hard part, a repeatable short plan usually helps. Read the assignment until you can state, in one sentence, what the program must do. Break that into data (what objects or values you need), actions (what the program must compute or repeat), and output (what must be printed). That approach answers the "what" before you touch the "how" — which is what , and others here are nudging toward when they ask for specifics.

Turn the problem into small, testable pieces. For a Chapter 5 task (conditionals and loops) that typically means: 1) design simple types (e.g. a Card with rank and suit), 2) store them in an array or ArrayList, 3) write one method that shuffles, 4) write one method that deals a hand, and 5) write a method that evaluates hand values using loops/ifs. Implement and run each piece before combining them. Desk-check the logic on paper, and use short hard-coded tests before adding user input.

Common student traps to watch for: off-by-one errors in loops, using == on strings, array index out of bounds, Scanner newline issues when mixing nextInt() and nextLine(), and forgetting to test a method in isolation. Compile and run often; a single failing method is easier to fix than a whole program that never starts. Use meaningful variable names and small helper methods so your main method stays readable.

Concrete hint — shuffle with Fisher-Yates and deal by advancing an index into the deck. Example shuffle and very small driver:

void shuffle(Card[] deck) {
  Random rnd = new Random();
  for (int i = deck.length - 1; i > 0; i--) {
    int j = rnd.nextInt(i + 1);
    Card tmp = deck[i];
    deck[i] = deck[j];
    deck[j] = tmp;
  }
}

public static void main(String[] args) {
  Deck deck = new Deck();
  deck.shuffle();
  Card[] hand = deck.deal(2);
  System.out.println(Arrays.toString(hand));
}

Post the smallest chunk of code that fails and say exactly what output you expected versus what happened — that will get faster, concrete help (as and suggested).

Recommended Answers

All 11 Replies

>Can you help me.
No, because you didn't even ask a question. Believe it or not, most of us probably won't have your crappy textbook on our shelves and even if someone does, the chances of them divining your homework assignment are nil.

hay ;
thats one of the best books for beginners... for the time being
u may use
Java 2 The Complele Reference by Herbert Schildt . :D

ask specific questions, don't ask people to do your homework.
If you're stuck post what you have and tell where you're stumped so people can direct you towards a solution (they may not even give you code, but tell you in words how to go about solving it).

The last thing professionals want is (more, there are quite a lot) of people entering the industry who can't write a line of code. By doing your homework for you that would be exactly what we would be causing.

what is ur quistion u didn't ask us to answer >>>>>

warm heart

That book is really good in terms of concepts ... you should be reading the text thoroughly. And then ask questions as you encounter problems ... but try to solve as many problems as possible ... as you'll learn more by solving not by asking.

Yeah, perhaps if you keep posting that question everywhere, we'll be more likely to help you with it.

sorry. my bad. I jus need help.

Hello,
I have the text book you are using. Post the problem you have, I will try to help you.

Ps
Don't give up. Learning Java is difficult but you can do it!

if he's not learned it in the past 6 years, he's never going to :)

Anyway, the book he refers to is the single worst piece of junk to learn Java from. It's only good as a doorstop.

Hello,
I have the text book you are using. Post the problem you have, I will try to help you.

Ps
Don't give up. Learning Java is difficult but you can do it!

Hi someone apparently posted this years ago, but I am in the same boat, taking a course using a book by the same author.. odd. Anyhow, I am taking the course online and have a few questions about how to begin a driver class for a program, that YES is an assignment. I have worked for days and still, clueless.
Anyhow, its a program to play Blackjack. I have been given a class that creates the card, its suit and its face value. (this is text only program there are no graphics)
I am trying to create a class that includes an array for the deck of cards (52) and use said array to "shuffle" the deck.
Then I need to create a driver class with a main method to create a new deck, shuffle it, and deal cards for two hands of blackjack, as a string... Ace Of Spades, Three of Clubs... that sort of thing.
I'm not asking anyone to do this for me, I want some help. If any one is feeling benevolent enough toassist me, you can email me at <EMAIL SNIPPED> .. or reply to this post.
here is how i have begun so far...but you may need to see the other class file to help me, so I am not sure..... ?

public class DeckOfCards
{
  int deck[] = new int [52];
  
  public class Card

Post a new thread for your question. Don't hijack other people's threads. And posting email addresses is not allowed here - keep questions on the forums.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.