-
Coding Problem
Hey all, I'm super new to programming, and have a project where I have to write a program that outputs the students names, along with two grades for each student, the average of those grades, then the average of the averages at the end. Finally, I have to have an output at the end that depends on what the total average was (if, then). The following is the code that I have so far, however I'm not supposed to "hard code" the grades as I've done, they're supposed to be entered as the program is run (which I can't figure out how to do). Could anyone help me figure out how to do this? I don't need a code written up doing my work for me, but an example would be an extremely huge help!
public class Project1 {
public static void main(String args[])
{
String s = "Student" + " " + "Names" + " " + "Score 1" + " " + "Score 2" + " " + "Average";
System.out.println(s);
String a = "Samuel" + " " + "Student" + " " + "100" + " " + "100" + " " + "100";
System.out.println(a);
String b = "Lindsay" + " " + "Student" + " " + "90" + " " + "86" + " " + "88";
System.out.println(b);
String c = "Chris" + " " + "Student" + " " + "52" + " " + "58" + " " + "55";
System.out.println(c);
}
}
This is what it's supposed to look like. (hope the link works...)
https://gcccd.blackboard.com/courses..._1/projec1.jpg
-
Re: Coding Problem
Hey BohmfalkCW,
The reason it is not encouraged to "Hard Code" through the assignment is because each individual may have different data/names, based on real life applications. This leads into User Input. Hopefully this video will give you an idea of how to begin. There are a plentiful amount of resources out there on the web. Make use of em!
Java - 6 - Getting User Input
-
Re: Coding Problem
use JOptionPane or Scanner for input. I found Scanner to be more useful.