Run the program grade1.java and type in your first name and the grades 80, 65, a
ID: 3589859 • Letter: R
Question
Run the program grade1.java and type in your first name and the grades 80, 65, and 98
Copy the code from grade1.java to the Word document
Copy the output to the Word document
Using the YELLOW text highlighter (in the word document) highlight the code that prompts for and reads in the name and three test scores
Using the PINK text highlighter (in the word document) highlight the code that does the course grade calculation
Using the BLUE text highlighter (in the word document) highlight the code that prints the final results
Next, run the program grade2.java and type in your first name and the grades 80, 65, and 98
Copy the code from grade2.java to the Word document
Copy the output to the Word document
Using the YELLOW text highlighter (in the word document) highlight the code that prompts for and reads in the name and three test scores
Using the PINK text highlighter (in the word document) highlight the code that does the course grade calculation
Using the BLUE text highlighter (in the word document) highlight the code that prints the final results
***I have completed the work below, I wanted to make sure i highlighted the correct code for both programs. I think I highlighted the correct lines of Code I am looking for assistance.
package Grade;
import javax.swing.JOptionPane;
public class Grade
{
public static void main(String[] args)
{
String name,data;
double test1;
double test2;
double test3;
double coursegrade;
name=JOptionPane.showInputDialog(null, "Enter the Name","Input Data", JOptionPane.QUESTION_MESSAGE);----YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test1=Double.parseDouble(data);---YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test2=Double.parseDouble(data);----YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test3=Double.parseDouble(data); ------YELLOW
coursegrade = 0.25*test1 + 0.25*test2 + 0.50*test3;-----PINK
System.out.println("student = "+name);--- BLUE
System.out.println("course grade: "+coursegrade);--BLUE
System.exit(0);
student = Chris
course grade: 85.25
package Grade2;
import javax.swing.JOptionPane;
public class Grade2
{
public static void main(String[] args)
{
String name;
double test1;
double test2;
double test3;
double coursegrade = 0;
// prompt for and obtain input from dialog boxes
name=get_name();
test1=get_test_score();
test2=get_test_score();
test3=get_test_score();
coursegrade=compute(test1,test2,test3);
print_all(name,coursegrade);----BLUE
System.exit(0);
}
public static String get_name()
{
String name;
name=JOptionPane.showInputDialog(null, "Enter the Name","Input Data", JOptionPane.QUESTION_MESSAGE);
return name;----YELLOW
}
public static double get_test_score()
{
String data;
double test;
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
exam=Double.parseDouble(data)---YELLOW;
return test;
}
public static double compute(double test1,double test2, double test3)
{
double coursegrade;------PINK
coursegrade = 0.25*test1 + 0.25*test2 + 0.50*test3;---PINK
return coursegrade;---PINK
}
public static void print_all(String name,double coursegrade)
{
System.out.println("student = "+name);----BLUE
System.out.println("course grade: "+coursegrade); ---BLUE
}
}
student = Chris
course grade: 85.25
Explanation / Answer
package Grade;
import javax.swing.JOptionPane;
public class Grade
{
public static void main(String[] args)
{
String name,data;
double test1;
double test2;
double test3;
double coursegrade;
name=JOptionPane.showInputDialog(null, "Enter the Name","Input Data", JOptionPane.QUESTION_MESSAGE);----YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test1=Double.parseDouble(data);---YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test2=Double.parseDouble(data);----YELLOW
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
test3=Double.parseDouble(data); ------YELLOW
coursegrade = 0.25*test1 + 0.25*test2 + 0.50*test3;-----PINK
System.out.println("student = "+name);--- BLUE
System.out.println("course grade: "+coursegrade);--BLUE
System.exit(0);
student = Chris
course grade: 85.25
package Grade2;
import javax.swing.JOptionPane;
public class Grade2
{
public static void main(String[] args)
{
String name;
double test1;
double test2;
double test3;
double coursegrade = 0;
// prompt for and obtain input from dialog boxes
name=get_name();.....YELLOW
test1=get_test_score();.....YELLOW
test2=get_test_score();.....YELLOW
test3=get_test_score();.....YELLOW
coursegrade=compute(test1,test2,test3);
print_all(name,coursegrade);----BLUE
System.exit(0);
}
public static String get_name()
{
String name;
name=JOptionPane.showInputDialog(null, "Enter the Name","Input Data", JOptionPane.QUESTION_MESSAGE);-----YELLOW
return name;----YELLOW
}
public static double get_test_score()
{
String data;
double test;
data=JOptionPane.showInputDialog(null, "Enter test score","Input Data", JOptionPane.QUESTION_MESSAGE);
exam=Double.parseDouble(data)---YELLOW;
return test;
}
public static double compute(double test1,double test2, double test3)
{
double coursegrade;------PINK
coursegrade = 0.25*test1 + 0.25*test2 + 0.50*test3;---PINK
return coursegrade;---PINK
}
public static void print_all(String name,double coursegrade)
{
System.out.println("student = "+name);----BLUE
System.out.println("course grade: "+coursegrade); ---BLUE
}
}
student = Chris
course grade: 85.25
Your highlighters were almost correct. Whereever those were missing Yeelow highlighter I have mentiones yellow against it. I hope it will be helpful to you.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.