Hey guys :idea:
This is my code

studNo = JOptionPane.showInputDialog(null, "Enter Student Number: ");
	studName = JOptionPane.showInputDialog(null, "Enter Student Name  : ");

	prelim = Float.parseFloat(JOptionPane.showInputDialog("Enter Prelim grade  : "));
	midterm = Float.parseFloat(JOptionPane.showInputDialog("Enter Midterm grade  : "));
	finals = Float.parseFloat(JOptionPane.showInputDialog("Enter Final grade  : "));

	
	overallGrade = (prelim * .2) + (midterm * .3) + (finals * .5);

	
	JOptionPane.showMessageDialog(null, "         Grade Computation" + "\n"
+ "Student No.     : " + studNo + "\n"
+ "Student Name: " + studName + "\n" + "\n"
+ "Grades: " + "\n" 
+ "     Prelims  : " + prelim + "\n" 
+ "     Midterm : " + midterm + "\n" 
+ "     Finals      : " + finals + "\n" + "\n" 
+ "Results:" + "\n" 
+ "      Overall Grades: " + overallGrade + "\n" + "\n"

 + "Created by: Sample" + "\n"
 + "Date completed: November 29, 2011");

 
            
	if (overallGrade >= 75) 
	JOptionPane.showMessageDialog(null, "      Remarks: Passed"); 
	if (overallGrade <= 75 && overallGrade >= 50) 
	JOptionPane.showMessageDialog(null, "      Remarks: Failed");
	else if (overallGrade <= 49) 
	JOptionPane.showMessageDialog(null, "      Remarks: Dropped");

so basically what I want is to put the remarks at that specified area and not print it separately


I run out of idea on how to do is, I'm hoping someone can help me with this.. Please, I'm begging anyone :)

Edited 5 Years Ago by Ashenvale: n/a

Attachments JOPTION.JPG 15.64 KB remarks.JPG 5.34 KB

if you want that, you have to put all of it in one String and show it using one JOptionPane MessageBox

one option:

String before = " Grade Computation" + "\n"
+ "Student No. : " + studNo + "\n"
+ "Student Name: " + studName + "\n" + "\n"
+ "Grades: " + "\n"
+ " Prelims : " + prelim + "\n"
+ " Midterm : " + midterm + "\n"
+ " Finals : " + finals + "\n" + "\n"
+ "Results:" + "\n"
+ " Overall Grades: " + overallGrade + "\n" + "\n";

String after = "\nCreated by: Sample" + "\n"
+ "Date completed: November 29, 2011";

String grade = "";

if (overallGrade >= 75)
grade =  " Remarks: Passed";
if (overallGrade <= 75 && overallGrade >= 50)
grade = " Remarks: Failed";
else if (overallGrade <= 49)
grade = " Remarks: Dropped";
String result = new String(before);
result.concat(grade);
result.concat(after);
JOptionPane.showMessageDialog(null, result);

I tried using the code you gave me but when I run it, this time, it doesn't show the remarks anymore

String result = new String(before);

plus this part has yellow highlights and it says Remove string constructor invocation

anyway, I tried removing it but still nothing happens, the remarks still won't show up. I don't know if I'm doing something wrong. gaah!! my head is all messed up..

Edited 5 Years Ago by Ashenvale: n/a

well ... I just wrote something in the lines of what you should do.
yes, String has no constructor which takes a String as parameter, but I figured you would figure that one out.
you can replace that line with

String result = before;

in your if statements, you can change the code in:

if (overallGrade >= 75)
 result +== " Remarks: Passed";
if (overallGrade <= 75 && overallGrade >= 50)
  result += " Remarks: Failed";
...
This question has already been answered. Start a new discussion instead.