9 Replies - 6043 Views - Last Post: 21 June 2011 - 11:35 PM Rate Topic: -----

#1 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

computing for final garde

Posted 18 June 2011 - 11:50 PM

i need help for this, i need the right computation for this code but the final grade isn't right what should i do?


Scanner input = new Scanner(System.in);
       int percent, mgrade, fgrade, longquiz1, longquiz2,squiz1, squiz2, sw1, sw2, hw1, hw2,midterm, finalexam, meval, mp1, mp2, mp3, proj, prac, feval, fmidterm, ffinalexam;
       String name, Longquiz;



        System.out.print("  Name of the Student:");
        name = input.nextLine();
        System.out.println(" \t\t\t\t\t\t Final Grade Computation");
        System.out.println("");
        System.out.println("\t\t\tLecture 70%");

        Scanner scan = new Scanner(System.in);

        //--------------------------------------------------------------------
        System.out.println("Long Quiz 40%");
        System.out.print("\tLong Quiz #1:");
        longquiz1= scan.nextInt();
        System.out.print("\tLong Quiz #2:");
        longquiz2= scan.nextInt();
        System.out.println("");
        double totalLongQuiz = ((longquiz1 + longquiz2)/2) * .40;
        System.out.println("Average: "+totalLongQuiz);


        System.out.println("");

        //--------------------------------------------------------------------
        System.out.println("Short Quiz 30%");
        System.out.print("\tShort Quiz #1:");
        squiz1= scan.nextInt();
        System.out.print("\tShort Quiz #2:");
        squiz2= scan.nextInt();
        double totalShortQuiz = ((squiz1 + squiz2)/2) * .30;
        System.out.println("Average: "+totalShortQuiz);
        System.out.println("");

        //--------------------------------------------------------------------
        System.out.println("Seatwork and Homework 25%");
        System.out.print("\tSeatwork #1:");
        sw1 = scan.nextInt();
        System.out.print("\tSeatwork #2:");
        sw2 = scan.nextInt();
        System.out.println("");

        System.out.print("\tHomework #1:");
        hw1 = scan.nextInt();
        System.out.print("\tHomework #2:");
        hw2 = scan.nextInt();
        System.out.println("");
        double totalHWSW = ((sw1 + sw2 + hw1 + hw2)/4) * .25;
        System.out.println("Average: "+totalHWSW);
        System.out.println("");

        //--------------------------------------------------------------------
        System.out.println("Midterm Exam 15%");
        System.out.print("\tMidterm Exam:");
        midterm = scan.nextInt();
        System.out.println("");
        double Mexam = midterm * .15;
        System.out.println("Average: "+Mexam);

        System.out.println("Final Exam 25%");
        System.out.print("\tFinal Exam:");
        finalexam = scan.nextInt();
        double totalFexam = finalexam * .25;
        System.out.println("Average: "+totalFexam);
        System.out.println("");

        //--------------------------------------------------------------------
        System.out.println("Evaluation 5%");
        System.out.print("\tEvaluation:");
        meval = scan.nextInt();
        double Eval = meval * .05;
        System.out.println("Average: "+Eval);
        System.out.println("");

        //---------------------------------------------------------------
        //Class Standing

        System.out.println("\tClass Standing:");
        double totalClassStanding =((totalLongQuiz + totalShortQuiz + totalHWSW +Eval)/4);
        double ClassStanding = totalClassStanding *.60;
        double Lecturegrade= ((Mexam + totalFexam + ClassStanding)/3);
        double LectureGrade= Lecturegrade * .70;
        //System.out.println("The Lecture Grade is: "+LectureGrade);


        //--------------------------------------------------------------
        //LAB

        System.out.println("\t\t\tLaboratory 30%");
        System.out.print("\tMachine Problem #1:");
        mp1 = scan.nextInt();
        System.out.print("\tMachine Problem #2:");
        mp2 = scan.nextInt();
        System.out.print("\tMachine Problem #3:");
        mp3 = scan.nextInt();
        double totalMProblem = ((mp1 + mp2 + mp3)/3) * .30;
        System.out.println("Average: "+totalMProblem);

        //----------------------------------------------------------------

        System.out.println("\t\t\tProject 30%");
        System.out.print("\tProject:");
        proj = scan.nextInt();
        double totalProj = proj * .30;
        System.out.println("Average: "+totalProj);

        System.out.println("\t\t\tPractical 25%");
        System.out.print("\tPractical:");
        prac = scan.nextInt();
        double totalPrac = prac * .25;
        System.out.println("Average: "+totalPrac);


        //-----------------------------------------------------------------

        System.out.println("Evaluation 5%");
        System.out.print("\tEvaluation:");
        feval = scan.nextInt();
        double fEval = feval * .05;
        System.out.println("Average: "+fEval);
        System.out.println("");
        
        

        //------------------------------------------------------------------

        System.out.println("Midterm Exam 15%");
        System.out.print("\tMidterm Exam:");
        fmidterm = scan.nextInt();
        double fMexam = fmidterm * .15;
        System.out.println("Average: "+fMexam);
        System.out.println("");

        System.out.println("Final Exam 25%");
        System.out.print("\tFinal Exam:");
        ffinalexam = scan.nextInt();
        double totalfFexam = ffinalexam * .25;
        System.out.println("Average: "+totalfFexam);
        System.out.println("");

        //-----------------------------------------------------------------

        double totalLabClassStanding =((totalMProblem + totalProj + totalPrac + fEval)/4);
        double LabClassStanding = totalLabClassStanding *.60;
       // System.out.println("Average: "+totalLabClassStanding);
        double totalLabgrade= ((Mexam + totalFexam + ClassStanding)/3);
        double LabGrade= totalLabgrade * .30;
        System.out.println("The Lab Grade is: "+LabGrade);

        //----------------------------------------------------------------

        double totalgrade = (LectureGrade + LabGrade );
        System.out.println("The Final Grade is: "+totalgrade);


    
    }


Mod Edit:
:code:!

Is This A Good Question/Topic? 0
  • +

Replies To: computing for final garde

#2 n8schatten  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 263
  • Joined: 07-December 10

Re: computing for final garde

Posted 19 June 2011 - 12:41 AM

Please use code-tags.

Currently there is too little information for us to help you. In what way is the final grade not correct? What do you expect to get and what are you actually getting? Are there any errors?
Was This Post Helpful? 0
  • +
  • -

#3 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

Re: computing for final garde

Posted 19 June 2011 - 12:45 AM

if i enter all 100 the final grade must be 100 but the result is 18.something and i don't know why, i believe my formulas are correct
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: computing for final garde

Posted 19 June 2011 - 04:35 AM

What is the formula you were given to calculate the answer? If you were given one, or if you developed one, does it work with the input you give it to get 100?
Was This Post Helpful? 1
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: computing for final garde

Posted 19 June 2011 - 06:15 PM

View PostLieannM, on 19 June 2011 - 02:50 AM, said:

i need help for this, i need the right computation for this code but the final grade isn't right

What is wrong with it ?
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10563
  • View blog
  • Posts: 39,087
  • Joined: 27-December 08

Re: computing for final garde

Posted 19 June 2011 - 06:53 PM

I'm not looking through 150+ lines of code if you can't narrow down your problem. However, at a glance, I did see this:
((squiz1 + squiz2)/2) * .30;



Since squiz1 and squiz2 are both ints, and 2 is an int, they are subject to integer division here. This means that if (squiz1 + squiz2) is not evenly divisible by 2, then the decimal place will get truncated. Dividing by 2.0 will solve this, as (squiz1 + squiz2) will be promoted to a double during the division.

I'd be willing to bet this is not the only place you should be concerned about this. Also, based on the output, where do things start messing up? Can you provide more details to help us help you?
Was This Post Helpful? 2
  • +
  • -

#7 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

Re: computing for final garde

Posted 21 June 2011 - 02:49 AM

thank you for those who replied and helped me I already got it. :)

This post has been edited by LieannM: 21 June 2011 - 02:50 AM

Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10563
  • View blog
  • Posts: 39,087
  • Joined: 27-December 08

Re: computing for final garde

Posted 21 June 2011 - 06:04 AM

Out of curiosity, would you mind sharing your final solution? :)
Was This Post Helpful? 0
  • +
  • -

#9 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

Re: computing for final garde

Posted 21 June 2011 - 10:50 PM

[b]double totalClassStanding =((totalLongQuiz + totalShortQuiz + totalHWSW +Eval)/4);[/b]
        double ClassStanding = totalClassStanding *.60;
        [b]double Lecturegrade= ((Mexam + totalFexam + ClassStanding)/3);[/b]
        double LectureGrade= Lecturegrade * .70;
      //System.out.println("The Lecture Grade is: "+LectureGrade);



i just did it this way .. i just remove the divisor.

[b]double totalClassStanding =(totalLongQuiz + totalShortQuiz + totalHWSW +Eval);[/b]
        double ClassStanding = totalClassStanding *.60;
        [b]double Lecturegrade= (Mexam + totalFexam + ClassStanding);[/b]
       double LectureGrade= Lecturegrade * .70;
        //System.out.println("The Lecture Grade is: "+LectureGrade);


This post has been edited by LieannM: 21 June 2011 - 10:55 PM

Was This Post Helpful? 0
  • +
  • -

#10 Rikka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 21-June 11

Re: computing for final garde

Posted 21 June 2011 - 11:35 PM

The divisor is the problem since the grade is based on the lecture and lab only. No need to divide it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1