//Muhammad Norat//TaskMNimport java.util.Scanner;public class print{ final static double BOLTS = 0.25; final static double NUTS = 0.15; final static double WASHERS = 0.10; public static void main (String [] args)throws Exception { Scanner in = new Scanner (System.in); //Initiate Variables String name = " "; String codeName = "Bobs Discount Bolts"; codeName = codeName.toUpperCase(); //[Cool123] I pulled this one out of the loop (Coz no use converting it each time) int bolts = 0; int nuts = 0; int washers = 0; int counter = 0; // [Cool123] Used to keep track of the customer number int namesize = codeName.length(); // Get the size of the name so we know it when creating random numbers System.out.println("Please enter the name of the customer "); name = in.next(); while (!name.equalsIgnoreCase("ZZZ")) //[Cool123] No need for extra brackets { // [Cool123] These create a random number between 0 and the length of the string // [Cool123] Below is the working of the invcode - see it and do yours int firstrandom = (int)((double)namesize * Math.random()); int secondrandom = (int)((double)namesize * Math.random()); int thirdrandom = (int)((double)namesize * Math.random()); counter++; //[Cool123] Increase the counter for the customer number String invcode = "" + codeName.charAt(firstrandom) + codeName.charAt(secondrandom) + codeName.charAt(thirdrandom) + counter; System.out.println(invcode); // [Cool123] I added this so you can see the output // [Cool123] End of the invcode calculation System.out.println("How many BOLTS are you purchasing ? "); bolts = in.nextInt(); System.out.println("How many NUTS are you purchasing ? "); nuts = in.nextInt(); System.out.println("How many WASHERS are you purchasing ? "); nuts = in.nextInt(); System.out.println("Please enter the name of the customer "); name = in.next(); } }}