-5

I am new to Java and I am trying to code a "Grading" system. Basically, when the code is ran, a window opens, it asks a question, you enter a number value, press enter, it loads another question, same process as before, hit enter, and repeat for the final time. At the end it takes those 3 numbers, does math and then displays a message. I have the basic code, I am just having issues with the popup window.

public class PopUp {

public static void main(String[] args) {

    // Constant grade worth percentage
    final int examWeight = 55;
    final int hwWeight = 20;
    final int activityWeight = 25;


    // Current grades
    double examGrade = 65.8;
    double hwGrade = 55.3;
    double activityGrade = 29.5;
    double finalGrade;

    // Math to figuring out final grade.
examGrade = examGrade * (examWeight / 100.0);
hwGrade = hwGrade * (hwWeight / 100.0);
activityGrade = activityGrade * (activityWeight / 100.0);
finalGrade = examGrade + activityGrade + hwGrade;

    //round thingy
    double rounded = Math.round(finalGrade *10)/10.0;

// What you made   
if (rounded>=90.0 && rounded<100.0) {
System.out.println("You made an A");
}
if (rounded>=85.0 && rounded<92.9) {
System.out.println("You made a B");
}
if (rounded>=75.0 && rounded<84.9) {
System.out.println("You made a C");
}
if (rounded>=67.0 && rounded<74.9) {
System.out.println("You made a D");
}
if (rounded<=59.9) {
System.out.println("You are a fucking failure");
}
System.out.println("Your final grade is: " + rounded);

}    
}

I need THAT code to display the information like this in a NEW WINDOW:

So basically:

Question one: 98.8 ENTER
Question two: 76.9 ENTER
Question three: 87.6 ENTER

Result: 93.3 END

In BlueJ the result I am trying to replicate in Eclipse is as follows:

    // Ask student to input scores for exam, lab and nomework
    IO.output("Enter your exam grade: ");
    examScore = IO.inputDouble( );
    IO.output("Enter your lab grade: ");
    labScore = IO.inputDouble( );
    IO.output("Enter your homework grade: ");
    hwScore = IO.inputDouble( );
Then the very end would be

    // Output the final grade
    IO.outputln("Your final grade is " + finalGrade); 

http://prntscr.com/9hicp6 -- Proof that it is a new window.

sebenalern
  • 2,515
  • 3
  • 26
  • 36
Zaqre
  • 9
  • 4
  • You should only include relevant code in your posts (i.e. we don't need to see your entire x-line program (where x is much greater than 10) if the problem is confined to less than 10 lines. Here, if you remove all the parts that already work and are therefore irrelevant to the popups, well, there's nothing left. This leaves us at a code-writing question. SO isn't a code writing service. Have you tried reading the documentation for popups in Java? – Arc676 Dec 23 '15 at 04:02
  • See [this post](http://stackoverflow.com/questions/8852560/how-to-make-popup-window-in-java) to find out exactly how to make popup windows. – Arc676 Dec 23 '15 at 04:03
  • I have used that post to make a popup window. It is not helpful at all, that is why I made this post. I used BlueJ and I have this: // Ask student to input scores for exam, lab and homework IO.output("Enter your exam grade: "); examScore = IO.inputDouble( ); IO.output("Enter your lab grade: "); labScore = IO.inputDouble( ); IO.output("Enter your homework grade: "); hwScore = IO.inputDouble( ); I cannot figure it out on Eclipse. Then the output for it would be // Output the final grade IO.outputln("Your final grade is " + finalGrade); – Zaqre Dec 23 '15 at 04:10
  • What IDE (programming app) you used is irrelevant (unless the compiler is bad or whatever). Don't post code in comments. You can [Edit] your post to show the code you have for the popups. While you're at it, you can remove the irrelevant parts of the code (i.e. the ones that already work and you don't need help with). – Arc676 Dec 23 '15 at 04:12
  • I understand it is irrelevant, that is why I am trying to figure out how to replicate the same result. – Zaqre Dec 23 '15 at 04:15
  • So what is `IO`? Given the function's you are calling, I doubt it's a popup. – Arc676 Dec 23 '15 at 04:18
  • The origin came from a file I received from a course on Java, it is ran through the BlueJ software. When the code is ran, it opens the BlueJ terminal (message window) which then allows to do enter the numbers like those shown in the links to screenshots that I provided. – Zaqre Dec 23 '15 at 04:24
  • Your question is incredibly unclear. You say you want to make popup windows. You say you have used the post that I suggested and it wasn't helpful. Then you post code that runs in a console (i.e. Terminal window, so nothing to do with popups). What are you trying to achieve? – Arc676 Dec 23 '15 at 04:27
  • ... I used BlueJ to get the windowed result that allowed me to type an answer, press enter and move on to the next question - again, as shown via the links provided. I am NOT using BlueJ anymore and I want the SAME effect as in BlueJ. My question is: How do I get the same result as when I was in BlueJ. The question is not that hard. Eclipse has button options, I do not want button options. I want it where a window pops up, asks a question, you answer, press "ENTER" and then another question pops up. Code Ran -> Window opens -> Asks question -> Answer and press "ENTER" -> Next question pops up. – Zaqre Dec 23 '15 at 04:32
  • Ah... Well I still don't know what `IO` is. In any case, use `System.out.println("...")` for printing to the console, and use either `java.util.Scanner` or `java.io.BufferedReader` for console input. Then just click the run button in Eclipse (the green play button). – Arc676 Dec 23 '15 at 04:41
  • The "IO" is the same thing as in "java.io.BufferedReader." java.------>io<------.BufferedReader – Zaqre Dec 23 '15 at 04:43
  • IO is Input/Output.... – Zaqre Dec 23 '15 at 04:47
  • That much was obvious. But `IO` can't be "the same thing" because `BufferedReader` doesn't have an `output` method. – Arc676 Dec 23 '15 at 04:47
  • And that's the problem -_- .... There is no output. – Zaqre Dec 23 '15 at 04:50
  • Um... because you're using the wrong class? As I said, use `System.out.println` for output. `BufferedReader` is, as the name suggests, a _reader_. It doesn't output. – Arc676 Dec 23 '15 at 04:52
  • Alright, let me do it this way. The window opens. The first question is "What is your BLA" you type 98.3 and hit ENTER. New question pops up. "What is your BLA" you type 87.3 and hit ENTER. Last question pops up. Same as the first two. I know how to use the println(""); that's not the problem. My original code uses them all the time System.out.println("Your final grade is: " + rounded); . I need a new window to show the information. – Zaqre Dec 23 '15 at 04:55
  • In that case you need someone who has used this `IO` thing in BlueJ, which isn't me. You can [edit] your post to clarify what you've clarified to me, i.e. what you _want_ is for a new _console window_ to appear, not what people usually mean when they say "popup window". – Arc676 Dec 23 '15 at 04:58
  • Again, for the 6th time. I am NOT, ~NOT~ using BlueJ anymore. I know how to get it to work in BlueJ, I DO NOT know how to work it in Eclipse. I want the same EFFECT as BlueJ but in ECLIPSE. – Zaqre Dec 23 '15 at 05:00
  • Exactly. And only someone who knows how the effect works in BlueJ can possibly know how to make the same thing work in Eclipse. – Arc676 Dec 23 '15 at 05:01

1 Answers1

0

If you want a popup windows maybe this will help you:

String grade = JOptionsPane.showInputDialog("Enter your grade:");

Good luck.

Jan
  • 13,738
  • 3
  • 30
  • 55