All pastes #393666 Raw Edit

taskMN

public java v1 · immutable
·published 2007-03-13 19:17 UTC
rendered paste body
//Muhammad Norat//TaskMNimport java.util.Scanner;public class TaskMN{	public static void main (String [] args)throws Exception	{		Scanner in = new Scanner (System.in);		//Initiate Variables		String name = " ";		String codeName = "BobsDiscountBolts";		int bolts = 0;		int nuts = 0;		int washers = 0;		int nameSize = 0;		int counter = 0;		int rand = 0;		double total = 0;		double vat = 0;		double grandTotal = 0;		codeName = codeName.toUpperCase();		System.out.println("      ************************************************************************");		System.out.println("    *                              >>>WELCOME TO<<<                            *");		System.out.println("   *                              -------------------                           *");		System.out.println("   *                             |BOBS DISCOUNT STORE|                          *");		System.out.println("   *                              -------------------                           *");		System.out.println("    *                           >>>BY  MUHAMMAD NORAT<<<                       *");		System.out.println("      *************************************************************************");		System.out.println("\n\n");		System.out.print("\tPLEASE ENTER THE NAME OF THE CUSTOMER\t: ");		name = in.nextLine();			while (!(name.equalsIgnoreCase("ZZZ")))			{			String invoice = " ";			counter ++;			System.out.println(" ");			System.out.print("\tHOW MANY BOLTS ARE YOU PURCHASING\t: ");			bolts = in.nextInt();			System.out.println(" ");			System.out.print("\tHOW MANY NUTS ARE YOU PURCHASING\t: ");			nuts = in.nextInt();			System.out.println(" ");			System.out.print("\tHOW MANY WASHERS ARE YOU PURCHASING\t: ");			washers = in.nextInt();			System.out.println("\n\n\n\n");			nameSize = codeName.length();			for (int x =1; x<=3; x++)				{				rand = (int)(nameSize * Math.random());				invoice = codeName.substring(rand,rand+1)+invoice;				}			double boltsPr = two.getBoltPr();			double nutsPr = two.getNutPr();			double washersPr = two.getWasherPr();			System.out.println("                        INVOICE PREPAIRED FOR: "+name.toUpperCase());			System.out.println("");			System.out.println("                       >>>BOB'S DISCOUNT STORE INVOICE #: "+counter+"<<<");			System.out.println("     **************************************************************************");			System.out.println("   *                            -------------------                             *");			System.out.println("  *   INV CODE: " + invoice+counter + "          |BOBS DISCOUNT STORE|                             *");			System.out.println("  *                             -------------------                              *");			System.out.println("  *                                                                              *");			System.out.println("  *   59 MAHATMA GANDHI STREET                  TELEPHONE : 552 1234             *");			System.out.println("  *   STANGER                                   FAX       : 552 5678             *");			System.out.println("  *   4450                                      E-MAIL    : BOBS@WEBMAIL.CO.ZA   *");			System.out.println("   *                                                                            *");			System.out.println("     **************************************************************************");			System.out.println("");			System.out.println("                                                                               ");			System.out.println("        ------         -----------         ----------         -----              ");			System.out.println("        NUMBER         DESCRIPTION         UNIT PRICE         TOTAL               ");			System.out.println("        ------         -----------         ----------         -----               ");			System.out.printf("      %8d           BOLT\\S             25c               R %10.2f        \n",bolts, bolts*boltsPr);			System.out.printf("      %8d           NUT\\S              15c               R %10.2f        \n",nuts, nuts*nutsPr);			System.out.printf("      %8d           NUT\\S              10c               R %10.2f        \n",washers, washers*nutsPr);			System.out.println("                                                                                 ");			System.out.println("                                                                               ");			System.out.println("");			total = bolts*boltsPr+nuts*nutsPr+washers*washersPr;			vat = total*14/100;			grandTotal = vat+total;			System.out.println("                                                                               ");			System.out.println("                                                                                 ");			System.out.printf ("             SUB TOTAL    -------------------------- R %10.2f                 \n",total);			System.out.print ("             VAT (@ 14%)  -------------------------- R ");			System.out.printf("%10.2f                 \n",vat);			System.out.printf ("             GRAND TOTAL  -------------------------- R %10.2f                 \n",grandTotal);			System.out.println("                                                                                 ");			System.out.println("                                                                               ");			System.out.println("");			if (bolts > nuts)			{			System.out.println("                                  !CHECK OUT THE ORDER!");			}else			System.out.println("                                  !ORDER IS CORRECT!");			System.out.println("                          PLEASE VISIT AGAIN.  HAVE A NICE DAY!!!");			System.out.println("\n\n\n\n");			Scanner input = new Scanner (System.in);			System.out.print("\tPLEASE ENTER THE NAME OF NEXT CUSTOMER\t: ");			name = input.next();			}	}}