在Linux下使用eclipse编写Java程序体验

在Linux下使用eclipse编写Java程序体验

今天实在是无聊然后呢就在Linux下使用eclipse写了一个Java自动售货机的程序后来,突然发现其实呢在Linux如果是用eclipse那么感觉就失去了很多的乐趣,可能也就只有我觉得百分之百的纯手写代码,是一种乐趣吧 !

话不多说,我们来直接看代码吧!

	package ziDongShouHuoJi;
	import java.util.Scanner;
	public class ZiDongShouHuoJi {
	public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	System.out.println("欢迎使用自动售货机 v1.0");	
	System.out.println("现在的货物有");
	System.out.println("1.可乐价格3元");
	System.out.println("2.冰红茶价格3元");
	System.out.println("3.绿茶价格3元");
	System.out.println("4.尖叫价格4元");
	System.out.println("5.退出");
	System.out.println("选择你需要的饮品");
	int a = in.nextInt();
	double c = 0.0;			
			while (a<=4) {
				if (a<4)
				{
					System.out.println("请投币3元");
					  c = in.nextDouble();
					  while(c<3)
					{
						System.out.println("已投币"+c+"元"+"需要3元");
						  double d = in.nextDouble();  
						  System.out.println(d);
						  c= c+d;
						  System.out.println(c);
					}
					System.out.println("拿好您的饮料"+"找您"+(c-3)+"元");
				}else
				{
				if (a==4) 
				{
					System.out.println("请投币4元");
					  c = in.nextDouble();
				  while(c<4)
						{
							System.out.println("已投币"+c+"元"+"需要4元");
							  double d = in.nextDouble();  
							  System.out.println(d);
							  c= c+d;
							  System.out.println(c);
						}
						System.out.println("拿好您的饮料"+"找您"+(c-4)+"元");
						
				}				
			}
				System.out.println("*****************************");
				System.out.println("现在的货物有");
				System.out.println("1.可乐价格3元");
				System.out.println("2.冰红茶价格3元");
				System.out.println("3.绿茶价格3元");
				System.out.println("4.尖叫价格4元");
				System.out.println("5.退出");
				System.out.println("选择你需要的饮品");
				 a = in.nextInt();	
		}			
	}
}

代码写的不是很简洁,命名也不是很规范,没有办法啊谁让我当时的英语就从来,没有及格过呢,,但是没有关系只要能跑起来完成我的目标就好了不是吗?

微信搜索大海的一天带你体验另类的编程!

猜你喜欢

转载自blog.csdn.net/qq_38929495/article/details/85953111