
Hi i would really be thankful if someone could help me with this
A program is required to ask users to rate the Java programming language using a number in the range 0 - 10.
The data input is ended by entering -1.
After all the votes have been counted, the program should output a table showing how many people gave each rating and the average rating.
import java.util.*;
class RateJava {
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Rate Java(0-10): "); int rate = input.nextInt(); while (rate > 10 || rate < 0) {
catch(
private static class IOException {
public IOException() {
}
} ArithmeticException e
);
{
System.out.println("Cannot calculate average - no data");
catch(IOException
);
{
System.out.println("Error reading from file");
} } }
}
System.out.print("Invalid! Rate Java within the range(0-10): ");
rate=input.nextInt();
System.out.println("You have rated Java: "+rate);

import java.util.*;
class RateJava
{
public static void main(String[] args)
{
int c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0,c10=0,c11=0;
Scanner input=new Scanner(System.in);
int rate=0;
do{
System.out.print("Rate Java(0-10): ");
rate=input.nextInt();
if(rate>10||rate<-1){
System.out.print("Invalid! Rate Java within(0-10): ");
rate=input.nextInt();
}
if(rate==0){
c1++;
}
if(rate==1){
c2++;
}
if(rate==2){
c3++;
}
if(rate==3){
c4++;
}
if(rate==4){
c5++;
}
if(rate==5){
c6++;
}
if(rate==6){
c7++;
}
if(rate==7){
c8++;
}
if(rate==8){
c9++;
}
if(rate==9){
c10++;
}
if(rate==10){
c11++;
}
if(rate==11){
c1++;
}
}
while(rate!=-1);
System.out.println();
System.out.println("*****RATINGS*****");
System.out.println("Number of users rated Java 0: "+c1);
System.out.println("Number of users rated Java 1: "+c2);
System.out.println("Number of users rated Java 2: "+c3);
System.out.println("Number of users rated Java 3: "+c4);
System.out.println("Number of users rated Java 4: "+c5);
System.out.println("Number of users rated Java 5: "+c6);
System.out.println("Number of users rated Java 6: "+c7);
System.out.println("Number of users rated Java 7: "+c8);
System.out.println("Number of users rated Java 8: "+c9);
System.out.println("Number of users rated Java 9: "+c10);
System.out.println("Number of users rated Java 10: "+c11);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.