I need to create a menu, and then depend on the choice, carry out a certain task. But sumhow any number i put in become sumthing else so the switch become deafualt. Can sum1 help?

``````import java.text.DecimalFormat;
import java.util.Scanner;

public class Lab0602_ATT
{
public static void main (String args[])
{
Scanner kb  = new Scanner(System.in);
DecimalFormat output = new DecimalFormat("0000.000");

do
{

System.out.println("1.  Given the Diameter, Compute the Area and Circumference");
System.out.println("2.	Compute Factorial");
System.out.println("3.	Fibonacci Sequence");
System.out.println("4.	GCF");
System.out.println("6.	Quit");
System.out.print("Choose option    ");

{
case '1' :
double area, circum = 0;
System.out.println("Enter Diameter");
int diameter  = kb.nextInt();
area = Math.PI*Math.pow((diameter/2),2);
circum = Math.PI*diameter;
System.out.println("Area ="+area);
System.out.println("Circumference ="+circum);
break;

case '2' :
break;

case '3' :
break;

case '4' :
break;

case '5' :
break;

case '6' :
break;

} //switch

}//main
}//Lab0602``````
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Eric Cute

just need sum help on how to fix it so it can carry out the task if I enter 1

I havent tried your code yet but since you declare menu as int, I think you dont need to enclose it in single quiotes in the case statement. try removing those and see what happens.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.