Note that there are some explanatory texts on larger screens.

plurals
  1. POjava grade report homework assignment
    primarykey
    data
    text
    <p>I am supposed to:</p> <ol> <li>create two constructors. a. query for student's names and three scores. b. take four arguments</li> <li>write a method calculateAvg that calculates and sets average</li> <li>write a method calculateGrade that calculates based on 90+=A, 80+=B, 70+=C, 60+=D, &lt;60=F</li> <li>Write a method toString that displays a gradeReport with the a. name b. three scores on a single line c. average and letter grade</li> <li>when the first constructor is used ensure that the scores are within 0-100. if not prompt again and explain why.</li> <li>format the output to exactly two decimal places</li> <li>format the output so that the scores are separated by tabs.</li> </ol> <p>I am not asking for this all to be done, but if you look at my code can you give me any leads on where I'm going wrong and what I might need to add?</p> <pre><code>import java.text.DecimalFormat; import java.util.Scanner; public class GradeReport { String name, name1, name2; int score1, score2, score3; double average; char grade; public GradeReport() //creates the first constructor { Scanner sc = new Scanner (System.in); System.out.println ("Enter student's first name: "); name1 = sc.nextLine(); System.out.println ("Enter the student's last name: "); name2 = sc.nextLine(); System.out.println ("Enter first grade: "); score1 = sc.nextInt(); System.out.println ("Enter second grade: "); score2 = sc.nextInt(); System.out.println ("Enter third grade: "); score3 = sc.nextInt(); } public GradeReport (String name, int score1, int score2, int score3) { } public void calculateAverage() { average = ((score1 + score2 + score3) / 3); DecimalFormat fmt = new DecimalFormat ("0.###"); //to format average to 2 decimal places } public void calculateGrade() { if (average &gt;= 90) System.out.println("A"); else if (average &gt;= 80) System.out.println("B"); else if (average &gt;= 70) System.out.println("C"); else if (average &gt;= 60) System.out.println("D"); else System.out.println("F"); } public String toString() { //System.out.println (name1, name2); String gradeReport = Double.toString(score1) + "\t," + Double.toString(score2)+ "\t," + Double.toString(score3); //String gradeReport = Double.toString(average); return gradeReport; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload