Question #105156
A school has three houses A, B and C. Write a program to read a house and the points awarded for winning each race in an athletic finals terminated by ā€œDā€. Calculate and print the total points gained by each house appropriately labeled. Also print the 1 St and 3rd house entered and the points.
1
Expert's answer
2020-03-12T07:49:14-0400

As per the given question,

The required program is given below,


import java.util.Scanner;

public class School {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int A, B,C, D;
        Scanner scan=new Scanner(System.in);
        System.out.println("---------Points gained by the houses of the school in the marathon--------------");
        // Point gained by House A,
        System.out.println("Please enter the points between 0- 10");
        
        System.out.println("Enter points gained by the house A ");
        A=scan.nextInt();
        if(0<A & A<10){
            System.out.println("Points gained by houses A:"+A);
        }else{
            System.out.println("Please enter the valid points between 0 to 10");
        }
                
        System.out.println("Enter points gained by the houses B");
        B=scan.nextInt();
        if(0<B & B<10){
            System.out.println("Points gained by houses A:"+B);
        }else{
            System.out.println("Please enter the valid points between 0 to 10");
        }
        
                
        System.out.println("Enter points gained by the house C");
        C=scan.nextInt();
        if(0<C & C<10){
            System.out.println("Points gained by houses A:"+C);
        }else{
            System.out.println("Please enter the valid points between 0 to 10");
        }
        
        
        scan.close();
        
        System.out.println("Points gained by 1st and 3rd house together:"+(A+C));
        
        

    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS