Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3307516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:24:55+00:00 2026-05-17T21:24:55+00:00

I am supposed to: create two constructors. a. query for student’s names and three

  • 0

I am supposed to:

  1. create two constructors. a. query for student’s names and three scores. b. take four arguments
  2. write a method calculateAvg that calculates and sets average
  3. write a method calculateGrade that calculates based on 90+=A, 80+=B, 70+=C, 60+=D, <60=F
  4. Write a method toString that displays a gradeReport with the a. name b. three scores on a single line c. average and letter grade
  5. when the first constructor is used ensure that the scores are within 0-100. if not prompt again and explain why.
  6. format the output to exactly two decimal places
  7. format the output so that the scores are separated by tabs.

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?

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 >= 90)
            System.out.println("A");
        else if (average >= 80)
            System.out.println("B");
        else if (average >= 70)
            System.out.println("C");
        else if (average >= 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;
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:24:55+00:00Added an answer on May 17, 2026 at 9:24 pm

    From your assignment you can work out the following about your code (Apologies for any syntactic errors, and please don’t jusge me for my lack of ability to write eligible Java after 3 years doing .net)

    Class GradeReport{
    //The values we get from the user
    private string name
    private int score1
    private int score2
    private int score3
    
    //Things we are told we need to calculate at some point
    private double average
    private char grade
    
    public GradeReport(){
    // Get values from the user and validate them
    
    // We will need to assign the values to the fields in some way 
    // here...do we have somewhere else to do that already written?
    }
    
    public GradeReport(String name, int score1, int score2, int score3){
    // We will probably want to assign these parameters to the fields here
    }
    
    public void calculateAverage(){
    // You already have that pretty much, but you prob don't need to output it to the screen
    }
    
    public void calculateGrade(){
    //Some sort of if...else logic is needed to work out the grade from the avg
    }
    
    public String toString(){
    // We need to output our various bit of information here in a nicely formatted String
    // I would recommend looking at String.Format() method in the Java API as a good starting point.
    
    // At some point you will need to call calculateGrade and calculateAverage. It would 
    // be useful to do that before you output to screen. It can either be done in here or 
    // in your main class before you call toString()
    }
    }
    

    I think you are pretty close to the answer you need, you just need to combine all the pieces. Look at Formatting strings in various ways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm supposed to create a simple rule engine in C#. Any leads on how
I'm working on an application that is supposed to create products (like shipping insurance
I want to create a very basic 3D modeling tool. The application is supposed
Let's assume, we create a stored procedure that is supposed to retrieve customer details
I create two application, let say my first application called mastersite, and the second
How are you supposed to create an autologin feature on your webpage using phpass
Suppose you create a generic Object variable and assign it to a specific instance.
Suppose I create a very simple socket connection, how can one programatically: Find out
Suppose I want to create a set of observers based on type. That is
Suppose I have a stored procedure that manages its own transaction CREATE PROCEDURE theProc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.