Thread: Need Java help Asap

Results 1 to 7 of 7
  1. #1 Need Java help Asap 
    Registered Member
    Join Date
    Dec 2016
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Your mission should you choose to accept it.
    -----------------------------------------------------


    Write a Java program that allows the teacher to calculate the grade for a student. The teacher will first enter the
    Student ID number, first name, and last name. This will be followed by entering in the score for each of the following
    categories: Assignments, Quizzes, Midterm Exam, & Final Exam
    The weights for each category are as follows:
    Assignments - 50%
    Quizzes – 20%
    Midterm – 10%
    Final – 20%
    Once you have the scores for each individual category, calculate a total score for the course. Then assign a letter grade
    to the student based on the following grade scale:
    90 – 100 = A
    80 – 90 = B
    70 – 80 = C
    60 – 70 = D
    < 60 = E
    Print the results in exactly the following format:
    [Last Name], [First Name]
    Student ID: [Student ID]
    Homework: [Homework Score]
    Quizzes: [Quizzes Score]
    Midterm: [Midterm Score]
    Final: [Final Score]
    Total Score: [Total Score] Grade: [Letter Grade]
    Then ask the user if they would like to enter another student or quit. Continue the process until the user chooses to
    quit.

    -----------------------------------------------------------------------------------------------------------------------------------------------
    This is what I have so far
    -----------------------------------------------------------------------------------------------------------------------------------------------

    import java.util.*;

    public class StudentGrades {

    public static void main (String[] args) {

    Scanner console = new Scanner (System.in);

    String sSID = "";
    String sInputF = "";
    String sInputL = "";
    String sGrade = "";
    double dWeightAssign = 50;
    double dWeightQuiz = 20;
    double dWeightMidE = 10;
    double dWeightFinalE = 20;
    double dStudentAssign = 0;
    double dStudentQuiz = 0;
    double dStudentMidE = 0;
    double dStudentFinalE = 0;
    double dTotalAssign = 0;
    double dTotalQuiz = 0;
    double dTotalMidE = 0;
    double dTotalFinalE = 0;
    double dTotalScore = 0;

    //Preform calculation
    dTotalAssign = dWeightAssign * dStudentAssign;
    dTotalQuiz = dWeightQuiz * dStudentQuiz;
    dTotalMidE = dWeightMidE * dStudentMidE;
    dTotalFinalE = dWeightFinalE * dStudentFinalE;
    dTotalScore = (dWeightAssign * dStudentAssign) + (dWeightQuiz * dStudentQuiz) +
    (dWeightMidE * dStudentMidE) + (dWeightFinalE * dStudentFinalE);


    //Get user input
    System.out.println("Please enter student's ID Number.");
    sSID = console.nextLine();

    System.out.println("Please enter student's First Name.");
    sInputF = console.nextLine();

    System.out.println("Please enter student's Last Name.");
    sInputL = console.nextLine();

    System.out.println("Please enter student's score for Assignments");
    dStudentAssign = console.nextDouble ();

    System.out.println("Please enter student's score for Quizes");
    dStudentQuiz = console.nextDouble ();

    System.out.println("Please enter student's score for Midterm Exam");
    dStudentMidE = console.nextDouble ();

    System.out.println("Please enter student's score for Final Exam");
    dStudentFinalE = console.nextDouble ();




    if (dTotalScore >= 90) {
    sGrade = "A";
    }
    else if (dTotalScore >= 80) {
    sGrade = "B";
    }
    else if (dTotalScore >= 70) {
    sGrade = "C";
    }
    else if (dTotalScore >= 60) {
    sGrade = "D";
    }
    else {
    sGrade = "F";
    }
    System.out.println(sGrade);

    -----------------------------------------------------------
    I have also tried the following for the letter grade
    -----------------------------------------------------------

    if (dTotalScore >= 90) {
    System.out.println("A");
    }

    else if (dTotalScore >= 80)
    {
    System.out.println("B");
    }

    else if (dTotalScore >= 70)
    {
    System.out.println("C");
    }

    else if (dTotalScore >= 60)
    {
    System.out.println("D");
    }

    else
    {
    System.out.println("F");
    }
    -----------------------------------------
    Neither way has worked
    -----------------------------------------


    }


    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    The problem (from what I can see) is that "dTotalScore" is only being called on on startup and getting a score of "0" because that's all you've ever asked it to do.

    First make it set to 0 at startup, then once you have the grades in, use the formula you originally have and make it equal to dTotalScore just before you calculate the letter grade.

    Edit: PS: Your calculations should be done AFTER the numbers have been entered. Otherwise you're getting no real value and hence not getting any proper answer.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2016
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Thank you Big Z, I'm having a bit of a problem understanding what you mean, sorry I'm super new to this.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Quote Originally Posted by Zalas View Post
    Thank you Big Z, I'm having a bit of a problem understanding what you mean, sorry I'm super new to this.
    Message me your Skype, be much easier on there!
    Reply With Quote  
     

  5. #5  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Quote Originally Posted by Zalas View Post
    Sorry, I don't have web cam
    I'm not interested in a web cam lol. I was hoping we could message on Skype as it's way easier and efficient and we don't spam up this thread.
    Reply With Quote  
     

  6. Thankful users:


  7. #6  
    Deathlypvpz Founder

    Join Date
    Aug 2012
    Posts
    486
    Thanks given
    6
    Thanks received
    116
    Rep Power
    43
    I haven't tested this but try this, threw it together in 5mins

    Code:
    import java.util.*;
    
    public class StudentGrades {
    
    	public static void main (String[] args) {
    		Scanner console = new Scanner (System.in);
    		
    		//Student Data Variables
    		String studentId = "";
    		String studentForename = "";
    		String studentSurname = "";
    		double assignmentScore = 0;
    		double quizScore = 0;
    		double midtermExam = 0;
    		double finalExam = 0;
    		double totalScore = 0;
    		String totalGrade = "";
    		
    		//Start Scanner Data input
    		System.out.println("Please enter student's ID Number.");
    		studentId = console.nextLine();
    
    		System.out.println("Please enter student's First Name.");
    		studentForename = console.nextLine();
    
    		System.out.println("Please enter student's Last Name.");
    		studentSurname = console.nextLine();
    
    		System.out.println("Please enter student's score for Assignments");
    		assignmentScore = console.nextDouble ();
    
    		System.out.println("Please enter student's score for Quizes");
    		quizScore = console.nextDouble();
    
    		System.out.println("Please enter student's score for Midterm Exam");
    		finalExam = console.nextDouble();
    
    		System.out.println("Please enter student's score for Final Exam");
    		finalExam = console.nextDouble();
    		
    		//Do calculations (Assuming that all scores are out of 100)
    		totalScore += ((assignmentScore + quizScore + midtermExam + finalExam) / 4);		
    		totalGrade += "Grade: " + (
    			totalScore > 89? "A" :
    			totalScore > 79? "B" :
    			totalScore > 69? "C" :
    			totalScore > 59? "D" : "E" 
    		);
    		
    		//Results
    		System.out.println("\n Results:-);
    		System.out.println("Last Name: " + studentSurname + " - First Name: " + studentForename);
    		System.out.println("Student ID: " + studentId);
    		System.out.println("Homework Score: What homework score?");
    		System.out.println("Quizzes Score: " + quizScore);
    		System.out.println("Midterm Exam Score: " + midtermExam);
    		System.out.println("Final Exam Score: " + finalExam);
    		System.out.println("Total Score: " + totalScore + " - " + finalExam);
    	}
    }
    Reply With Quote  
     

  8. #7  
    Registered Member Final Form's Avatar
    Join Date
    Aug 2015
    Posts
    29
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Zalas View Post
    Your mission should you choose to accept it.
    -----------------------------------------------------


    Write a Java program that allows the teacher to calculate the grade for a student. The teacher will first enter the
    Student ID number, first name, and last name. This will be followed by entering in the score for each of the following
    categories: Assignments, Quizzes, Midterm Exam, & Final Exam
    The weights for each category are as follows:
    Assignments - 50%
    Quizzes – 20%
    Midterm – 10%
    Final – 20%
    Once you have the scores for each individual category, calculate a total score for the course. Then assign a letter grade
    to the student based on the following grade scale:
    90 – 100 = A
    80 – 90 = B
    70 – 80 = C
    60 – 70 = D
    < 60 = E
    Print the results in exactly the following format:
    [Last Name], [First Name]
    Student ID: [Student ID]
    Homework: [Homework Score]
    Quizzes: [Quizzes Score]
    Midterm: [Midterm Score]
    Final: [Final Score]
    Total Score: [Total Score] Grade: [Letter Grade]
    Then ask the user if they would like to enter another student or quit. Continue the process until the user chooses to
    quit.

    -----------------------------------------------------------------------------------------------------------------------------------------------
    This is what I have so far
    -----------------------------------------------------------------------------------------------------------------------------------------------

    import java.util.*;

    public class StudentGrades {

    public static void main (String[] args) {

    Scanner console = new Scanner (System.in);

    String sSID = "";
    String sInputF = "";
    String sInputL = "";
    String sGrade = "";
    double dWeightAssign = 50;
    double dWeightQuiz = 20;
    double dWeightMidE = 10;
    double dWeightFinalE = 20;
    double dStudentAssign = 0;
    double dStudentQuiz = 0;
    double dStudentMidE = 0;
    double dStudentFinalE = 0;
    double dTotalAssign = 0;
    double dTotalQuiz = 0;
    double dTotalMidE = 0;
    double dTotalFinalE = 0;
    double dTotalScore = 0;

    //Preform calculation
    dTotalAssign = dWeightAssign * dStudentAssign;
    dTotalQuiz = dWeightQuiz * dStudentQuiz;
    dTotalMidE = dWeightMidE * dStudentMidE;
    dTotalFinalE = dWeightFinalE * dStudentFinalE;
    dTotalScore = (dWeightAssign * dStudentAssign) + (dWeightQuiz * dStudentQuiz) +
    (dWeightMidE * dStudentMidE) + (dWeightFinalE * dStudentFinalE);


    //Get user input
    System.out.println("Please enter student's ID Number.");
    sSID = console.nextLine();

    System.out.println("Please enter student's First Name.");
    sInputF = console.nextLine();

    System.out.println("Please enter student's Last Name.");
    sInputL = console.nextLine();

    System.out.println("Please enter student's score for Assignments");
    dStudentAssign = console.nextDouble ();

    System.out.println("Please enter student's score for Quizes");
    dStudentQuiz = console.nextDouble ();

    System.out.println("Please enter student's score for Midterm Exam");
    dStudentMidE = console.nextDouble ();

    System.out.println("Please enter student's score for Final Exam");
    dStudentFinalE = console.nextDouble ();




    if (dTotalScore >= 90) {
    sGrade = "A";
    }
    else if (dTotalScore >= 80) {
    sGrade = "B";
    }
    else if (dTotalScore >= 70) {
    sGrade = "C";
    }
    else if (dTotalScore >= 60) {
    sGrade = "D";
    }
    else {
    sGrade = "F";
    }
    System.out.println(sGrade);

    -----------------------------------------------------------
    I have also tried the following for the letter grade
    -----------------------------------------------------------

    if (dTotalScore >= 90) {
    System.out.println("A");
    }

    else if (dTotalScore >= 80)
    {
    System.out.println("B");
    }

    else if (dTotalScore >= 70)
    {
    System.out.println("C");
    }

    else if (dTotalScore >= 60)
    {
    System.out.println("D");
    }

    else
    {
    System.out.println("F");
    }
    -----------------------------------------
    Neither way has worked
    -----------------------------------------


    }


    }
    I think I still have this assignment. I can check if i do i got a 95% on it if i do still have it i can send you it.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Need NPC help! asap please.
    By shopkeeper in forum Help
    Replies: 2
    Last Post: 12-14-2011, 12:24 PM
  2. need delta help asap lol!
    By disaster call in forum Help
    Replies: 2
    Last Post: 09-17-2011, 12:45 PM
  3. Replies: 10
    Last Post: 07-10-2010, 04:17 PM
  4. Easy Science Stuff Need Some Help ASAP!
    By Dragroxas in forum Homework
    Replies: 2
    Last Post: 11-10-2009, 03:11 PM
  5. Need urgent help asap
    By Poptart in forum Help
    Replies: 0
    Last Post: 01-19-2009, 08:49 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •