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));
}
}
Comments
Leave a comment