Finding The Issue With This Code.

AxleBlaze_AxleBlaze_ India
edited January 2015 in Java Beginners
import java.util.Scanner;
class Percentage {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.println("Input to all exam scores should be out of 90, UTs 20 and FA combinations from 10");

System.out.println("Enter Your English UT1 Score: ");
double English = input.nextDouble();
System.out.println("Enter Your English UT2 Score: ");
double English1 = input.nextDouble();
System.out.println("Enter Your English FA1 + FA2 Score: ");
double English2 = input.nextDouble();
System.out.println("Enter Your English Exam Score: ");
double English3 = input.nextDouble();
System.out.println("Enter Your English UT3 Score: ");
double English4 = input.nextDouble();
System.out.println("Enter Your English UT4 Score: ");
double English5 = input.nextDouble();
System.out.println("Enter Your English FA3 + FA4 Score: ");
double English6 = input.nextDouble();
System.out.println("Enter Your English Exam2 Score: ");
double English7 = input.nextDouble();

double UT = (English + English1)/4;
double FA = English2;
double Exam = English3/3;
double UT1 = (English4 + English5)/4;
double FA1 = English6;
double Exam1 = English7/3;

double Average = UT + FA + Exam + UT1 + FA1 + Exam1;





System.out.println("Enter Your Math UT1 Score: ");
double Math = input.nextDouble();
System.out.println("Enter Your Math UT2 Score: ");
double Math1 = input.nextDouble();
System.out.println("Enter Your Math FA1 + FA2 Score: ");
double Math2 = input.nextDouble();
System.out.println("Enter Your Math Exam Score: ");
double Math3 = input.nextDouble();
System.out.println("Enter Your Math UT3 Score: ");
double Math4 = input.nextDouble();
System.out.println("Enter Your Math UT4 Score: ");
double Math5 = input.nextDouble();
System.out.println("Enter Your Math FA3 + FA4 Score: ");
double Math6 = input.nextDouble();
System.out.println("Enter Your Math Exam2 Score: ");
double Math7 = input.nextDouble();

double UT2 = (Math + Math1)/4;
double FA2 = Math2;
double Exam2 = Math3/3;
double UT3 = (Math4 + Math5)/4;
double FA3 = Math6;
double Exam3 = Math7/3;

double Average1 = UT2 + FA2 + Exam2 + UT3 + FA3 + Exam3;





System.out.println("Enter Your Science UT1 Score: ");
double Science = input.nextDouble();
System.out.println("Enter Your Science UT2 Score: ");
double Science1 = input.nextDouble();
System.out.println("Enter Your Science FA1 + FA2 Score: ");
double Science2 = input.nextDouble();
System.out.println("Enter Your Science Exam Score: ");
double Science3 = input.nextDouble();
System.out.println("Enter Your Science UT3 Score: ");
double Science4 = input.nextDouble();
System.out.println("Enter Your Science UT4 Score: ");
double Science5 = input.nextDouble();
System.out.println("Enter Your Science FA3 + FA4 Score: ");
double Science6 = input.nextDouble();
System.out.println("Enter Your Science Exam2 Score: ");
double Science7 = input.nextDouble();

double UT4 = (Science + Science1)/4;
double FA4 = Science2;
double Exam4 = Science3/3;
double UT5 = (Science4 + Science5)/4;
double FA5 = Science6;
double Exam5 = Science7/3;

double Average2 = UT4 + FA4 + Exam4 + UT5 + FA5 + Exam5;






System.out.println("Enter Your Social Studies UT1 Score: ");
double Social = input.nextDouble();
System.out.println("Enter Your Social Studies UT2 Score: ");
double Social1 = input.nextDouble();
System.out.println("Enter Your Social Studies FA1 + FA2 Score: ");
double Social2 = input.nextDouble();
System.out.println("Enter Your Social Studies Exam Score: ");
double Social3 = input.nextDouble();
System.out.println("Enter Your Social Studies UT3 Score: ");
double Social4 = input.nextDouble();
System.out.println("Enter Your Social Studies UT4 Score: ");
double Social5 = input.nextDouble();
System.out.println("Enter Your Social Studies FA3 + FA4 Score: ");
double Social6 = input.nextDouble();
System.out.println("Enter Your Social Studies Exam2 Score: ");
double Social7 = input.nextDouble();

double UT6 = (Social + Social1)/4;
double FA6 = Social2;
double Exam6 = Social3/3;
double UT7 = (Social4 + Social5)/4;
double FA7 = Social6;
double Exam7 = Social7/3;

double Average3 = UT6 + FA6 + Exam6 + UT7 + FA7 + Exam7;






System.out.println("Enter Your Language UT1 Score: ");
double Language = input.nextDouble();
System.out.println("Enter Your Language UT2 Score: ");
double Language1 = input.nextDouble();
System.out.println("Enter Your Language FA1 + FA2 Score: ");
double Language2 = input.nextDouble();
System.out.println("Enter Your Language Exam Score: ");
double Language3 = input.nextDouble();
System.out.println("Enter Your Language UT3 Score: ");
double Language4 = input.nextDouble();
System.out.println("Enter Your Language UT4 Score: ");
double Language5 = input.nextDouble();
System.out.println("Enter Your Language FA3 + FA4 Score: ");
double Language6 = input.nextDouble();
System.out.println("Enter Your Language Exam2 Score: ");
double Language7 = input.nextDouble();


double UT8 = (Language + Language1)/4;
double FA8 = Language2;
double Exam8 = Language/3;
double UT9 = (Language4 + Language5)/4;
double FA9 = Language6;
double Exam9 = Language7/3;

double Average4 = UT8 + FA8 + Exam8 + UT9 + FA9 + Exam9;

double Total = Average + Average1 + Average2 + Average3 + Average4;

double Percentage = (100/450) * Total;

System.out.println("Your total percentage is " + Percentage +"%");
                 }
 }

Sorry for the extremely clumsy code, I'm really new to this.

So I checked the code again and again, and while there seem no issues, after it takes all inputs correctly, the percentage still comes out to be 0.0%. I have no idea why.

Comments

  • SixtyHzSixtyHz US
    edited January 2015

    try:
    line 159 change (100/450) to (100.0/450.0)

    why:
    100 and 450 are integers so 100/450 = 0

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion