Total Score Recommendation Points Earned
>500 Excellent 4
350 – 499 Very Good 3
200 – 249 Good 2
<249 Not good enough 1
I need to write a java code and compile it using Switch statements? Anyone can help thanks
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Total Score Recommendation Points Earned
>500 Excellent 4
350 – 499 Very Good 3
200 – 249 Good 2
<249 Not good enough 1
I need to write a java code and compile it using Switch statements? Anyone can help thanks
Do you have any specific questions about your assignment?
Please post your code and any questions about problems you are having.
What have you tried? - Matt Gemmell
switch statements aren't much good for ranges of data.
If you don't understand my answer, don't ignore it, ask a question.
/*Question :
* Complete the requirement of the program to determine the meaning
* and population using Switch Statment.
* Note this time I am looking for the appropriate exception handling with a
* correct loop to continue until user ask to exit the program.
*/
package midterm;
import java.util.Scanner;
public class Midterm {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
String recommendation;
String pointsEarned;
System.out.println("Enter your score now!");
int score = input.nextInt();
switch (score ){
case 1:
if (score >=500){
recommendation = "Excellent";
pointsEarned = "43%";
}
break;
case 2:
if (score>=350 && score<=499){
recommendation = "Excellent";
pointsEarned = "43%";
}
break;
case 3:
if (score>=249 && score<=200){
recommendation = "Excellent";
pointsEarned = "43%";
}
break;
case 4:
if (score < 200){
recommendation = "Excellent";
pointsEarned = "43%";
}
break;
}
}
}
--- Update ---
it does not complie and i still need to use try and catch
Please copy the full text of the error messages and post it here.it does not complie
What values can the user enter? What will the switch statement do with those values?
Please edit your post and wrap your code with code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Check your clipboard. The copy and paste feature on your PC is not working correctly.
If you don't understand my answer, don't ignore it, ask a question.
Hello all,
the whole community of java can't compile a switch statement, really? need help guys..
Please copy the full text of the error messages you are getting and post it here.
Please edit your post and wrap your code with code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.