Image

Imagecrazylikefox wrote in Imagejava_dev 😊contemplative

Introduction & Questions

Hello :)

I have recently started adventuring into the Java sphere.  I am a n00blet.  I enjoy firearms, belly dancing, and linguistics.  When it comes to the geek arts I am still a novice.  That being said, I am working on learning more, and currently am on hour ten of "Sams Teach Yourself Java in 24 Hours".  It has to do with creating objects.  Hour 9 was very intense with multidimensional arrays.  I still have questions on those.

They say to be a good programmer you have to be good with logic puzzles.  So here is a puzzle I would like help with, if you guys have the time.

Here is the original code from hour 7, which is using conditional tests to make decisions:

http://workbench.cadenhead.org/book/java-6-24-hours/source/chapter7/NoteGrade1.java

What I am trying to do is modify it a little here:

package Java24;
import java.util.Scanner;

class Grade {
    public static void main(String[] args) {
        Scanner langi = new Scanner(System.in);
        int grade = 24242424;
        if (grade > 89)  {
            System.out.println("You got an A. Great job!");
        } else if (grade > 79) {
            System.out.println("You got a B. Good work!");
        } else if (grade > 69) {
            System.out.println("You got a C. You'll never get into a good college!");
        } else if (grade <= 101) {
            System.out.println("You are a fool.");
        } else {
            System.out.println("You got an F. You'll do well in Congress!");
        }
    }
}

Two things I am trying to do:

1.  I am trying to get the program to ask me what my number grade was instead of putting a number directly into the code with int grade = 24242424.  Haven't been successful yet.

2.  I am trying to have the program output "You are a fool." if you put in a score higher than 100.  Right now it is just seeing that the score is higher than 89 and prints the line and that is the end of it.

Any help would be greatly appreciated!

Thanks :)