Computer Science, asked by shamik06grp, 10 months ago

WAP to input customer name, product name, product price in shop (JAVA)​

Answers

Answered by seetadevi281
0

Answer:

Regarding checking a valid CSU ID, you should combine the conditions using OR.

if ((min1<=id && id <= max1) || (min2<=id && id <= max2)) { } else {} // Not valid

You can make a method called isValidId(int id, int min, int max), but I'll leave that up to you.

Anyways, looks like you need a Map<String, Double>

For example,

Map<String, Double> amounts = new HashMap<>(); amounts.put("bookbag", 40.00); amounts.put("textbook", 50.00); ...

Then, to add values, read from the Scanner, and store in the array, then get its value

for(int i = 0; i < items; i++ ) { System.out.println("What would you like to purchase?"); String c = read.nextLine(); itemArray[i] = c; sum += amounts.get(c);

Similar questions