我們需要創建一個菜單,可以使用字符 (如A.B.C也可以選擇)來選擇。灣C。並使用Q.退出。如何創建菜單以在Java中使用字符A B C或b c進行選擇
package mainmenu;
import java.util.Scanner;
public class MainMenu{
public static void main(String[] args){
System.out.println(" Welcome to our project");
System.out.println("Please Choose an option from the menu");
System.out.println("Type the letter to select the option");
System.out.println();
// We need to create a menu that can be selected using Characters
//such as A. B. C. also a. b. c. and use Q. to quit.
在這裏,我們將設置菜單有7個選項:
一直在尋找一種方式來創建一個使用字母和方式將它們轉換爲一個大寫的菜單。
/* A. The Radius of a circle.
B. The Cost of gym membership over a year.
C. Compound Interest of CD over 6 years.
D. The Square Root of a 5 digit number.
E. Guess the number Game.
F. Day of your birth day.
G. Little Shop of Horrors.
Q. Quit/Exit.
*/
// A. Radius of a Circle
// Scan for the Diameter then display the Results
// B. Cost of a Gym Membership
// Scan for the Gym info, Name, joining fee, monthly cost, yearly dues, cancellation fee.
// double joinFee, monthCost, yearDues, cancelFee.
// double initialCost = joinFee + monthCost;
// double yearlyCost = initialCost + (monthCost * 11) + yearDues;
// double earlycancel = (monthCost * 2) + cancelFee;
// Display the options
// C. Compound Interest of CD over 6 year period
/*
A=P(1+R)^N
double amount;
double principal = 10000 ;
double rate = .01;
for(double months=1; months<=60; months++){
amount=principal * Math.pow(1 + rate, months);
System.out.println (months + " " + amount); }
*/
// D. Calculate the Square Root of a 5 digit number
// E. Guess the Number Game
// Too low
// Too high
// F. Day of the week of your Birthday.
// Calculate the Day and display
// G. When should Seymour feed the plant
// Feed me Seymour!!
// Feed him in the morning, in the afternoon, in the evening and at midnight.
// Q. Quit/Exit
這聽起來像一個家庭作業問題,我看不出你有任何嘗試自己解決它。 – DavidS 2015-02-23 03:33:27