thats what I'm trying to do:
* If user inputs 3, onscreen message should say "A triangle has 3 sides."
* If user inputs 4, onscreen message should say "A rectangle has 4 sides."
* If user inputs 5, onscreen message should see "A pentagon has 5 sides."
and here is my code:
import java.util.Scanner;
public class helloWorld{
public static void main(String[] args) {
String userInputStringOfAngles; // Declare a variable of type String to capture user input
int numberOfAngles; // Declare a variable of type int to hold the converted user input
Scanner myInputScannerInstance = new Scanner(System.in); // Recognize the keyboard
System.out.print("Please type the integer press Enter: "); // Prompt the user
userInputStringOfAngles= myInputScannerInstance.next(); // Capture user input as string
numberOfAngles = Integer.parseInt(userInputStringOfAngles); // Convert the string to a number in case this will be useful later
}
int numberOfAngles=3;// LINE 1. CODE TO DETERMINE WHETHER USER INPUT IS OUT OF BOUNDS GOES HERE
String userInputStringOfAngles;
switch (numberOfAngles){
case '3' : userInputStringOfAngles="3"
break;
case '4': userInputStringOfAngles="4"
break;
case '5':userInputStringOfAngles="5"
break;
default :
System.out.println("Invalid input");
// LINE 2. SWITCH CODE TO PRINT CORRECT "SHAPE" MESSAGE BASED ON USER INPUT GOES HERE
}
}
if (userInputStringOfAngles==3){
System.out.println("A triangle has 3 sides. ");
};
else if (userInputStringOfAngles==4){
System.out.println("A rectangle has 4 sides");
};
else if (userInputStringOfAngles==5){
System.out.println("A pentagon has 5 sides");
}
else System.out.println("Invalid input");
}};