import java.util.Scanner;
class AbstractReceipt{
String[] names;
int[] costs;
int itemCount;
{
this.names = new String[5];
this.costs= new int[5];
this.itemCount =0;
}
public void addItem(String name,int cost){
this.names[this.itemCount] = name;
this.costs[this.itemCount] = cost;
this.itemCount++;
}
public void show(){
} public int getTotalAmount(){ int total =0; for (int i = 0;i < this.itemCount;i++){ total +=this.costs[i]; } return total; } void showBody() { for(int i =0; i < this.itemCount; i++){ System.out.println(this.names[i]); System.out.println(" " +this.costs[i] +"円"); } System.out.println(); System.out.println("合計"+ getTotalAmount()+ "円"); }
class Receipt{
void showHeader(){
System.out.println("KCG BOOK CENTER");
System.out.println("TEL:075-671-1911");
System.out.println("-----------------");
} void showFooter(){ System.out.println("------------------"); System.out.println("ありがとうございました"); }
}
public class MainReceipt {
public static void main(String [] args){
Scanner sc =new Scanner(System.in);
System.out.println("購入した商品と価格を入力してください。5商品まで終了はQ");
String S = sc.nextLine();
int N = sc.nextInt();
}
}
}
これらを組み合わせてレシートのプログラムを作りたいのですがこの先どうすればいいか教えてください。
あなたの回答
tips
プレビュー