Can any one help me? Our instructor said that he does'nt want to use array list in our program. And only array,for loops,and do while only. The program is a Purchase program.(Adding item, records the transactions.) This is the first step i want to understand.
In this program, i want do display item code and descip properly. For example code=123 and descrip= yeah. The output displays, Item code = 123, Item descrpition = yeah.
But once i say yes and i put another, example code =456 and desription = oh. Output Item code = 123456, Item description = yeah.oh.
import java.util.Scanner;
public class Apps {
public static void main(String[] args) {
Scanner a = new Scanner(System.in);
String code = "", des = "", ans;
String[] b = new String[1];
String[] aw = new String[1];
int x;
do {
System.out.print("Item code:");
code += "" + a.next();
System.out.print("des:");
des += "" + a.next();
System.out.println("yes or no:");
ans = a.next();
}
while (ans.equals("yes"));
for (x = 0; x < 1; x++) {
b[x] = code;
aw[x] = des;
System.out.println("Item code:" + b[x]);
System.out.println("Item description:" + aw[x]);
}
}
}
Copyright Notice:Content Author:「Raymond」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19296519/purchase-java-part-2