package com.forkeon.test;
import java.util.Scanner;
/**
- 循環(huán)
- while do...while for
- while 語法:
- do while語法:
- do{
- }
- while();
- for 循環(huán)
- break 跳出循環(huán)
- continue 結(jié)束本次循環(huán)執(zhí)行下次循環(huán)
- @author Administrator
*/
public class loopdemo {
public static void main(String[] args) {
/* for (int i = 0; i < 10; i++) {
System.out.println(i);
}
String name="";// 商業(yè)名稱
double price=0.0;//商品價格
int productNo=0;//商品編號
System.out.println("............");
System.out.println("請選擇你要購買的商品的編號");
System.out.println("1.鋼琴 2.吉他 3.鍵盤");
System.out.println(".............");
Scanner input=new Scanner(System.in);
String answer="y";//表示是否繼續(xù)
while (answer.equals("y"))
{
System.out.println("請輸入商品編號");
productNo=input.nextInt();
switch (productNo)
{
case 1:
name="鋼琴";
price=20000;
break;
case 2:
name="吉他";
price=15000;
break;
case 3:
name="鍵盤";
price=40000;
break;
}
System.out.println(name+"....."+price);
System.out.println("是否繼續(xù)(y/n)");
answer=input.next();
}
System.out.println("退出程序...");
/* int x=1;
while (x<=10) {
int y=0;
System.out.println(x);
x++;
}
System.out.println("asfsdfaf");
System.out.println("asfasf"); */
}
}