Student Test Grade Program

/*
IT205 Intro to Object Oriented Programming
Programmer: Carter Hendrick
Date: October 24, 2025
Pledge: This program is entirely written by me (Carter Hendrick) without help from anyone except starter program
Starter program for Module2 program assignment.
You may modify this program for your submission

notes:
syntax of a static method (method definition)
accessModifier static returntype methodName(formal parameter list){body}

syntax of formal paramter list: datatype par1,datatype para2,….

method call is always methodName(arguments)

syntax for arguments is var1, var2,…

important: cannot have a method definition within other method definitions
*/
package module2_assignment_carterhendrick;
import java.util.Scanner;

public class Module2 {

public static void main(String[] args) {
    // write program here here
    //calling header method here
    headerMethod();

    //declare variables here
    String firstName;
    String LastName;
    String letterGrade = null;
    String Exit = null;
    double score1;
    double score2;
    double score3;
    double TotalScore;
    double scoreAverage;

    Scanner input = new Scanner(System.in);

    System.out.print("Press Enter or type exit to quit: ");
    Exit = input.nextLine();

    //start while loop here
  while (!"exit".equalsIgnoreCase(Exit)){

    //call the getNameMethod
    firstName = getfirstNameMethod();
    LastName = getlastNameMethod();

    //call the scores method 3 times
    score1 = gettestscoremethod();
    score2 = gettestscoremethod();
    score3 = gettestscoremethod();

    //call the total method
    TotalScore = getTotalTestScoreMethod(score1, score2, score3);

    //call the average method
    scoreAverage = getTestAverageMethod(TotalScore);

    //call the lettergrade method
    letterGrade = getLetterGradeMethod(scoreAverage, letterGrade);

    //call the output method
    outputMethod(firstName, LastName, score1, score2, score3, TotalScore, scoreAverage, letterGrade);

    //ask and read if they want another student

    System.out.printf("%-15s%15s%n", "Full Name", firstName + " " + LastName);//goes into the output method

     System.out.print("Press Enter or type exit to quit: ");
    Exit = input.nextLine();

  }//end of while loop

}//end of main

//******************************************
//void method without parameters

public static void headerMethod(){
    System.out.println("**********************************************");
    System.out.println("* IT205 Intro to Object Oriented Programming *");
    System.out.println("* Programmer: Carter Hendrick                *");
    System.out.println("* Date: October 24, 2025                     *");
    System.out.println("**********************************************");


}//end of headerMethod

//**********************************************************************
//value returning method without parameters
//prompt, read, and return full name

public static String getfirstNameMethod(){
    //declare variables
    Scanner input = new Scanner(System.in);
    String someName;

    //prompt and read full name
    System.out.print("Enter your first name: ");
    someName = input.nextLine();

    //return the name
    return someName;


}//end getfirstnamemethod
 //**********************************************************************
//value returning method without parameters
//prompt, read, and return full name

public static String getlastNameMethod(){
    //declare variables
    Scanner input = new Scanner(System.in);
    String someName;

    //prompt and read full name
    System.out.print("Enter your last name: ");
    someName = input.nextLine();

    //return the name
    return someName;


}//end getlastnamemethod
//*****************************************************************
//method to prompt and read a score -call this method 3 times from main
public static double gettestscoremethod(){

    //declare variables
    Scanner input = new Scanner(System.in);
    double Score;

    //prompt and read test score
System.out.printf("%s","Enter the students test score: ");
    Score = input.nextDouble(); //input first test score

    return Score;

}

//method to calculate the total value returning with 3 parameters
public static double getTotalTestScoreMethod(double score1, double score2, double score3){

    //Declare Variables
    double TotalScore;

    TotalScore = score1 + score2 + score3;

    return TotalScore;
}

//method to calculate the average value returning with 1 parameters
public static double getTestAverageMethod(double TotalScore){

    double scoreAverage;

    scoreAverage = TotalScore/3;

    return scoreAverage;
}
//method to calculate the letter grade value returning with 1 parameters
public static String getLetterGradeMethod(double scoreAverage, String letterGrade) {

     if (scoreAverage >= 90) //If statement for assigning letter grade to test score
            { 
                letterGrade = "A" ;
            } else if (scoreAverage >= 80){
                letterGrade = "B";
            } else if (scoreAverage >= 70) {
                letterGrade = "C";
            } else {
                letterGrade = "F";
            }
     return letterGrade;
}

//output method for formatted results void method with name, total, average, and letter grade parameters
public static void outputMethod(String firstName, String LastName,double score1, double score2, double score3, double TotalScore, double scoreAverage, String letterGrade){
           System.out.printf("%s%n%s%n%s%n%s%n%s%n%s%n%s%n%s%n%s%n%s%n", //Display the students name and their average test score
            "The students first name is: " + firstName, 
            "The Students last name is: " + LastName, 
            "The students test scores are: ", score1, score2, score3,
            "The students total score number is: ", TotalScore,
                     "Their average test score is: " + scoreAverage,
                     "The students Letter grade is: " + letterGrade); 
}

}//end of module2

Leave a Reply

Your email address will not be published.