Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Java (https://www.askmehelpdesk.com/showthread.php?t=816922)

  • Oct 9, 2015, 06:11 AM
    staurt47
    Java
    With switches as well
    import java.util.Scanner;
    public class Lab1
    {
    public static void main (String[]args)
    {
    double exam_score, assessment_score, total_score, real_fee=100.0, my_fee;
    Scanner in = new Scanner(System.in);

    int grade;
    System.out.println("please enter your exam score");
    exam_score = in.nextDouble();
    System.out.println("please enter your assessment_ score");
    assessment_score = in.nextInt();
    if (exam_score>100 || assessment_score>30)
    System.out.println("Enter correct scores for the components");
    total_score = exam_score + assessment_score;
    System.out.println("Your total score is " + total_score );
    if(exam_score >= 25 && assessment_score >= 15)
    {
    if (total_score>=70)
    System.out.println("You got 'A'");
    else if (total_score>=60)
    System.out.println("you got 'B'");
    else if (total_score>=50)
    System.out.println("you got 'c'");
    else if (total_score>=40)
    System.out.println("you got 'D'");
    }
    else
    {
    if (exam_score==25 && assessment_score==14)
    System.out.println("You have passed but condoned. You failed in the assessment");
    if (exam_score==24 && assessment_score==15)
    System.out.println("You have passed but condoned. You failed in the exam");
    }
    System.out.println("How much have you paid as fees?");
    my_fee = in.nextDouble();
    if (my_fee<real_fee)
    System.out.println("You cant get any Certificate. You owe fees");
    if (my_fee==real_fee)
    System.out.println("You have been awarded a Certificate in this course");
    }
    }
  • Oct 9, 2015, 07:08 AM
    CravenMorhead
    Switches are meant to be used to replace if/else trees.

    Also the conditional where you check if the exam score is 25/24 and the assessment score is 14/15 seems ot be a little odd, is this how you're supposed tohave this according to your assignment spec?

  • All times are GMT -7. The time now is 03:11 AM.