If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Thread: OMG nee JAVA (not javascript) help!

1. OMG nee JAVA (not javascript) help!

OK - I need help with this - it's commented so if anyone can help me out I'd really be grateful.
This is for a school assignment, and I can't see what the prof is writing on the screen...
Code:
```public class GradeCalc {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
//1.Ask user for max points
System.out.println("What is the max points you can attain?");
int maxPoints = input.nextInt();

System.out.println("The max points is: " + maxPoints);

//2. Ask user how many points attained
System.out.println("What is the max points you got?");
int myPoints = input.nextInt();

System.out.println("The max points I got is: " + myPoints);

//3. Display % of points attained
//how to do this?
double (myPercent
System.out.println("The max points I got is: " + myPercent);
//4. Display the letter grade
int testscore = 76;
//arbitrary number here - not sure how to get it into the equation below

if (testscore >= 90) {
} else if (testscore >= 80) {
} else if (testscore >= 70) {
} else if (testscore >= 60) {
} else {
}
// this only works if the original max points is 100 - if it were different it would not work...
}
}```

2.

3. Are you just trying to figure out how to calculate the grade?
If so, syntax is on you because I don't know Java, but:
Code:
`(myPoints/maxPoints)*100`

4. OK - that's like PHP, so I get that - now I have to figure out how to write whatever will fetch myPoints and get it into the equation...

I am not sure I'm ready for this...

5. Perhaps this? How To Use Divide By In Java - Java | Dream.In.Code
Which seems like:
Code:
```double myPercent = (myPoints / maxPoints) * 100;
// Or possibly
int myPercent = (myPoints / maxPoints) * 100;```
Man, we might just end up learning Java together...

6. I've been looking things up for hours - my head is spinning - I may drop this and just go with Advanced PHP...

This was described as a beginners course - there are 25 in the class and everyone but me has a background in something that works like JAVA; C#, C++, some are there to "brush up" on their JAVA. The guy beside me has been programming in C for twenty years, and C++ for seven... But what he writes is not the same as what the Prof writes on the big screen, so it does me no good. His stuff works - he and the prof discuss why their approaches are different - but I don't need to learn more than one way to do things at this point!

This is a government-sponsored course (Quebec pays the tuition), and the guy teaching it actually works in the business, so it is up-to-date, but it seems many of the people in the class already know a lot of this and are there just for the certification, not for the knowledge. And so we are going forward really fast, and I am very much afraid I'm going to get left behind. I have three classes to decide if I'm going to drop it - if I drop after the cutoff date I have to pay the tuition, and it's about \$1200. Also, if I fail at midterms, they kick me out and I have to pay. So it's a big decision.

I'll let you know when I get it working

7. I didn't try getting the conditional for the grade letter to work, but after some digging thru the Java API, I wrote this, which I was able to compile and successfully run:
Code:
```//Not sure what this is, but apparently you're supposed to import Scanner before you use it.
import java.util.Scanner;
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//Declare some variables. Discovered that using double is key here.
double maxPoints;
double myPoints;
double myPercent;
System.out.print("Max possible: ");
//Store it. Lather, rinse, repeat.
maxPoints = input.nextInt();
System.out.print("Input your score: ");
myPoints = input.nextInt();
myPercent = (myPoints/maxPoints)*100;
//Round your percent. Guessed on whether this was a thing in Java. Totally nailed it.
myPercent = Math.round(myPercent);
System.out.println("Your percentage is: " + myPercent + "%");
}
}```

8. Jeez - I forgot about that - we did import Scanner - we're using eclipse with the Android ADT bundle, and it give you lists of hints (kind of like DW) and you can import and install automatically (kind of like the Linux repository).

We imported it for an earlier exercise and I guess it just stayed resident in the program.

I have had a discussion with the program co-ordinator and we spoke to the Prof - the upshot is that I'm going to drop this in favor of advanced PHP, to will give me a better basis for the JAVA, then re-enroll next year. It's a bit of a bummer, but I'd rather do it right than stumble through it and not get all I can from the course. Since I already know a bit about PHP, I'm going to concurrently take the course in HTML5 and CSS3, so it's not so bad.

Anyway, thank for the help - I'm still trying to figure out the math - what the thing is supposed to do is:

1. when compiled, the program should print out the question "What are the max points available?"
2. the user inputs a number
3. then the program prints out the question "How many points did you get?"
4. the user inputs a second number
5. using those two numbers, the program calculates the percentage value of the user's points and prints it out
6. then the program calculates the letter grade based on the percentage and prints it out.

I'm going to pick up a "JAVA for Dummies" or something and see how that goes - the HTML5/CSS3 is on weekends only and the PHP doesn't start until January, so maybe I'll have some time to play around.

9. Man, I gotta get the government of Ontario to start sponsoring me and give me free education.

How'd you pull that off, Mare?

10. Originally Posted by TheGAME1264
Man, I gotta get the government of Ontario to start sponsoring me and give me free education.

How'd you pull that off, Mare?
Move to a bigoted, xenophobic, narcissistic province that wants to develop a captive French unilingual workforce so they can separate from Canada, and trains them on the federal equalization transfer dime?

11. If it wasn't so damn cold there, CALISS, count me in!

(You forgot "sexually degenerate", by the way).

Page 1 of 2 1 2 Last