JAVA 프로그래밍

문제

아메리카노, 라떼, 에스프레소를 주문받아 영수증을 출력하는 문제입니다 실행순서를 클릭하세요 
아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: 1
아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: 2
아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: 3
아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: 4
항      목   단가  개수
-----------------------
아메리카노   3500   1
라      떼   4000   1
에스프레소   3000   1
-----------------------
합      계   10500원 

프로그램 코드

	import java.util.Scanner;

	class Coffee
	{
		private static int total  = 0;
		private String name;
		private int cost;
		private int count;
		
C1b		public Coffee( String name, int cost ) {
			this.name = name;
			this.cost = cost;
			this.count = 0;
C1e		}

C2b		public void add() {
			this.count++;
			this.total += this.cost;
C2e		}

C3b		public String toString() {
			if( this.count == 0 )
				return "";
			else
				return this.name + "   " + this.cost + "   " + this.count + "\n";
C3e		}
		
C4b		public static int total() {
			return total;
C4e		}
	}

	public class CoffeeOrder
	{
1		public static void main (String[] args ) {
			Scanner scan = new Scanner( System.in );
2			Coffee[] coffee = {
3			                    new Coffee( "아메리카노", 3500 ),
4			                    new Coffee( "라      떼", 4000 ),
5			                    new Coffee( "에스프레소", 3000 )
			                   };
			                   
			System.out.print( "아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: " );
6			for( int order = scan.nextInt(); ( order == 1 ) || ( order == 2 ) || ( order == 3 ); order = scan.nextInt() ) {
7				coffee[ order - 1 ].add();
				System.out.print( "아메리카노(1), 라떼(2), 에스프레소(3) 중 하나를 선택하세요: " );
			}
			
			System.out.println( "\n항      목   단가  개수\n-----------------------" );
8			for( Coffee item : coffee )
9				System.out.print(
10				                  item );
11			System.out.println( "-----------------------\n합      계   "
12			                    + Coffee.total() + "원" );
			scan.close();
13		}
	}








 
실행 순서