Ask Experts Questions for FREE Help !
Ask
    staurt47's Avatar
    staurt47 Posts: 2, Reputation: 1
    New Member
     
    #1

    Oct 9, 2015, 06:11 AM
    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");
    }
    }
    CravenMorhead's Avatar
    CravenMorhead Posts: 4,532, Reputation: 1065
    Adult Sexuality Expert
     
    #2

    Oct 9, 2015, 07:08 AM
    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?

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

What all topics comes under advance java?what is framework how it is related to java? [ 0 Answers ]

I want to know about the topics related to advance java?and how the framework likke struts and hibernate realted to each other?what are there uses?

I am new to java GUI and multiple classes, I have knowledge of core java. I have [ 0 Answers ]

Sir, I am new to java GUI and multiple classes, I have knowledge of core java. I have to call a rest client from my net beans project give values to it and receive it's output in the same project. Please suggest me what I need to study and what to do.

Java netbeans program- Connection between java and mysql,How to conn [ 0 Answers ]

which I wrote from a book but when I run it, it shows exception please give me the code to connect jlistbox to database when I click on btn1. btn coding should search "name" in database and shows all the names in listbox my coding: here-- r1,r2,r3 are radio btns and l1,l2,l3 are labels,...

Java [ 1 Answers ]

public class Over { public int stack(int j, int k) { return j + k; } public int stack(int m) { return m * m; } public int stack(float f) { return (int)f * 5; } public static void main(String args) { int n = 3;


View more questions Search