Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is the Assignment Program Description: This assignment will give you pract

ID: 3668437 • Letter: B

Question

Below is the Assignment
Program Description:
This assignment will give you practice with parameters, returning values, and interactive programs. Turn in a
Java class named Grades in a file named Grades.java, which will be submitted electronically on the course
web site. You will be using a Scanner object for console input, so you will need to import java.util.*;
into your program.
This program uses a student's grades on homework and exams to compute an overall course grade. The
following is one example log of execution of the program (user input is underlined).
This program accepts your homework scores and
scores from two exams as input and computes
your grade in the course.
Homework and Exam 1 weights? 50 20
Using weights of 50 20 30
Homework:
Number of assignments? 3
Assignment 1 score and max? 14 15
Assignment 2 score and max? 16 20
Assignment 3 score and max? 19 25
Sections attended? 4
Total points = 65 / 80
Weighted score = 40.63
Exam 1:
Score? 81
Curve? 0
Total points = 81 / 100
Weighted score = 16.2
Exam 2:
Score? 95
Curve? 10
Total points = 100 / 100
Weighted score = 30.0
Course grade = 86.83
The course grade is a weighted average. To
compute a weighted average, the student's point
scores in each category are divided by the total
points for that category and multiplied by that
category's weight.
Part of the homework score is determined by how
many discussion sections the student attended.
Each section is worth 4 points, up to a maximum of
20 possible section points.
In the log of execution shown, the course has 50%
weight for homework, 20% weight for exam 1, and
30% weight for exam 2. There are 3 homework
assignments worth 15, 20, and 25 points
respectively. The student received homework
scores of 14, 16, and 19, and attended 4 sections
(earning 16 points for doing so). The student
received an exam 1 score of 81. The student
earned an exam 2 score of 95; the exam was
curved by +10 points, but exam scores are capped
at 100, so the student was given 100 for exam 2.
The following calculations produce the student's course grade from the above log of execution:

( 14+16+29(4*4) /15+20+25+20 x50 ) + (81/100 x20) + (100/100 x30)


Note that the preceding equations are not Java math. In Java, an integer expression such as 81/100 would
evaluate to 0, but above the value intended is 0.81.
The program behaves differently depending on the user input it receives; you should look at all of the example
logs of execution on the course web site to get a more comprehensive example of the program's behavior.
2 of 2
Program Behavior Details:
The program asks the user for the weights of the homework and exam 1. Using this information, the program
can deduce the weight of exam 2 as 100 minus the other two weights.
You may assume that the user enters valid input. For example, assume that the user enters a number of
homework assignments no less than 1, and that the sum of category weights entered will be no more than 100.
The weight of a particular category (homework, exam 1, or exam 2) will be non-negative but could be 0.
You should handle the following two special cases of user input:
A student might receive extra credit on a particular assignment, so for example 22 / 20 is a legal assignment
score. But the total points for homework are capped at the maximum possible. For example if a student
receives 63 total points out of a maximum of 60, your program should cap this to 60 / 60.
The maximum score for an exam is 100. If the curved exam score exceeds 100, a score of 100 is used.
Use the Math.max and Math.min methods to constrain numbers to a given range.
Notice that all weighted scores and grades printed by the program are shown with no more than 2 digits after the
decimal point. To achieve this, you may type the following method into your program and call it to round a
double value to the nearest hundredth:
// Returns the given double value rounded to the nearest hundredth.
public static double round2(double number) {
return Math.round(number * 100.0) / 100.0;
}
The following is an example usage of this method to print a variable named x:
System.out.println("The rounded value of x is " + round2(x));
See the logs of execution on the course web site. Your program's output should match these examples exactly
when the same input is typed. Please note that there are some blank lines between sections of output and that
input values typed by the user appear on the same line as the corresponding prompt message.
The code to compute the student's homework scores requires you to compute a cumulative sum.
Stylistic Guidelines:
A major part of this assignment is demonstrating that you understand parameters and return values. Therefore,
use static methods that accept parameters and return values where appropriate for structure and to eliminate
redundancy. For full credit, you must use at least 3 non-trivial methods other than main and round2.
You can have println statements in your main method on this program. However, your main method should
still represent a summary of the overall program; the majority of the behavior should come from other methods.
To fully achieve this goal, some of your methods will need to return values back to their caller. Each method
should perform a coherent task and should not do too large a share of the overall work. For reference, my
solution is 87 lines long with 5 methods other than main.
When handling numeric data, you are expected to choose appropriately between types int and double.
For this assignment you are limited to the language features in Chapters 1 through 3. You are not allowed to
use more advanced features (such as if/else statements) or features not covered in class or the textbook to
solve the problem.
You should properly indent your code and use whitespace to make your program readable. Give meaningful
names to methods and variables in your code. Follow Java's naming and capitalization standards as described
in Section 1.2 of the book. Localize variables whenever possible; declare them in the shortest possible scope.
Include a comment at the beginning of your program with basic information and a description of the program.
Also include a comment at the start of each method explaining its behavior.

I am having issues applying round2 so that all numbers are rounded to 2 decimal places and I previoulsy was having issues with non static items being referenced so i added obj. to create the connection to call non static variables but that is not correct since it was not in the chapters that we can use. Below is my code if some guidance could be given on removing the obj and correctly getting round 2 implemented would be great help.

------------------------------------------------------------------

import java.util.Scanner;

public class Grades1
{
    double assign1;
    double assign2;
    double assign3;
    double max1;
    double max2;
    double max3;
    int discuss;
    int discussMax;
    double homeworkWeight;
    double examOneWeight;
    double examTwoWeight;
    double curveAmount;
    double score;
    double scoreTotal;
    double scoreWeighted1;
    double scoreWeighted2;
    double scoreWeightedHw;
    int section;
    int sections;
    double sumScore;
    double number;
    double assignMax;
    double assignScore;
    int sumMax;
    double courseGrade;
    double weightedHomework;
    double weightedScoreOne;
    double weightedScoreTwo;

   Scanner console = new Scanner(System.in);

   public static void main(String[] args) {
      
        Grades1 obj = new Grades1();
       obj.intro();
       obj.homework();
       obj.examOne();
       obj.examTwo();
       obj.courseGrade();
   }
   public void intro() {
       System.out.println("This program accepts scores from two exams and");
       System.out.println("scores from your homework as input and computes");
       System.out.println("your grade in the course.");
       System.out.println();
       System.out.print("Homework and Exam 1 weights?");
       examOneWeight= console.nextInt();
       homeworkWeight = console.nextInt();
      examTwoWeight= console.nextInt();
   }
   public void homework() {
       System.out.print("Homework:");
       System.out.print("Number of assignments?");
       number = console.nextInt();

       for (int i = 1; i <= number; i++) {
           System.out.println("Assignment " + i + " score and max?");
           assignScore = console.nextInt();
           assignMax = console.nextInt();
           sumScore += assignScore;
           sumMax += assignMax;
       }
       System.out.print("Sections attended?");
       section = console.nextInt();
       sections = Math.min(4 * section, 20);
       System.out.println("Section points = " + sections);

       weightedHomework();

       System.out.println("Total points = " + (sections + sumScore) + "/"
               + sumMax);
       System.out.println("Weighted score = " + scoreWeightedHw);
   }
   public void examOne() {
         System.out.println("");
           System.out.println("Exam 1:");
           System.out.print("Score?");
           score = console.nextInt();
           System.out.print("Curve?");
           curveAmount = console.nextInt();
          
           totalScore();
           weightedScoreOne();

           System.out.println("Total points = " + scoreTotal + "/" + "100");
           System.out.println("Weighted score = " + scoreWeighted1);
    }
   public void examTwo() {
           System.out.println("");
           System.out.println("Exam 2:");
           System.out.print("Score?");
           score = console.nextInt();
           System.out.print("Curve?");
           curveAmount = console.nextInt();
          
           totalScore();
           weightedScoreTwo();

           System.out.println("Total points = " + scoreTotal + "/" + "100");
           System.out.println("Weighted score = " + scoreWeighted2);
    }
   public void totalScore() {
       scoreTotal = Math.min(score + curveAmount, 100);
   }
   public void weightedScoreOne() {
       scoreWeighted1 = (score + curveAmount)/200.00 * examOneWeight;
   }
   public void weightedScoreTwo() {
       scoreWeighted2 = (score + curveAmount)/200.00 * examTwoWeight;
   }
   public void weightedHomework() {
       scoreWeightedHw = ((sections + sumScore)/sumMax)*homeworkWeight;
   }
   public void courseGrade() {
       courseGrade=(scoreWeightedHw + scoreWeighted1 + scoreWeighted2 );
      System.out.println("Course grade = "+ courseGrade);
   }
   public static double round2(double n){
      return Math.round(n * 100.0) / 100.0;
   }
}

Explanation / Answer

import java.io.*;

class Student

{

public static void main ( String args[] )

throws IOException

{

BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

System.out.print(" Enter no. of students : ");

int n = Integer.parseInt ( br.readLine() );

String name[] = new String[n];

String div[] = new String[n];

int sub[][] = new int[n][6];

int total[] = new int [n];

float per[] = new float[n];

for ( int i=0 ; i<n ; i++ )

{

System.out.println(" Enter details of Student " + (i+1) + " - ");

System.out.print(" Enter name : ");

name[i] = br.readLine();

System.out.println(" Enter marks in 6 subjects - ");

System.out.print(" SE = ");

sub[i][0] = Integer.parseInt ( br.readLine() );

System.out.print(" CA = ");

sub[i][1] = Integer.parseInt ( br.readLine() );
  
System.out.print(" DMS = ");

sub[i][2] = Integer.parseInt ( br.readLine() );

System.out.print(" CG = ");

sub[i][3] = Integer.parseInt ( br.readLine() );

System.out.print(" TF = ");

sub[i][4] = Integer.parseInt ( br.readLine() );

System.out.print(" ITC = ");

sub[i][5] = Integer.parseInt ( br.readLine() );

for ( int j=0 ; j<6 ; j++ )

total[i] += sub[i][j];

per[i] = (float)total[i]/6;

if ( per[i] >= 70 && per[i] < 100 )

div[i] = "Honours";

else if ( per[i] >= 60 && per[i] < 70 )

div[i] = "1st";

else if ( per[i] >= 45 && per[i] < 60 )

div[i] = "2nd";

else if ( per[i] >= 33 && per[i] < 45 )

div[i] = "3rd";
else

div[i] = "Fail";

}

System.out.println(" Student Record - ");

System.out.print(" Name ");

System.out.print("SE ");

System.out.print("CA ");

System.out.print("DMS ");

System.out.print("CG ");

System.out.print("TF ");

System.out.print("ITC ");

System.out.print("Total ");

System.out.print("% ");

System.out.println("Div ");

for ( int i=0 ; i<n ; i++ )

{

System.out.print(name[i] + " ");

System.out.print(sub[i][0] + " ");

System.out.print(sub[i][1] + " ");

System.out.print(sub[i][2] + " ");   

System.out.print(sub[i][3] + " ");   

System.out.print(sub[i][4] + " ");

System.out.print(sub[i][5] + " ");

System.out.print(total[i] + " ");

System.out.print(per[i] + " ");

System.out.print(div[i] + " ");

System.out.println(" ");

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote