Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create well written, Java program for a small business to use as a cash register

ID: 3548961 • Letter: C

Question

Create well written, Java program for a small business to use as a cash register.

The program initialize by asking the user for information about
*Number of $1 bills in the cash drawer
*Number of $5 bills in the cash drawer
*Number of $10 bills in the cash drawer
*No need to deal with coins or larger bills

Once the cash drawer is initialized(this happens only once as the program starts), program Inputs will be
*Sale
*Purchaser's name
*User will input for each item in an order(input until the item purchase is "-99")
*Description of the item purchased
*How many of this item was purchased
*Price for one item (every item will cost $1, $2, $5, $7, $9, or $10 - no other price is allowed)
*Amount paid in the number of $5 bills and $10 bills - users never pay with $1 bills, they just get $1 as change
*A user may purchase up to 20 items

Program Output will be
*Name
*For each item
*Item Desctiption
*Number of this item purchased
*Price per item
*Total price for this item
*How much the user paid - total of all bills
*The exact up of the change; how many $10s, how many $5s, and how many $1s
*Total cost of the order
*The "cash on hand" and the program will show
*Number of $1 bills
*Number of $5 bills
*Number of $10 bills
*The total value of all the cash in the cash dawer.





The grading Criteria for this program:
Notes / IPO
Comments and white space
User Friendly Input and output
Proper use of Decisions
Proper use of Loops
Proper use of Array
Proper use of Encapsulation
Proper Programming

Explanation / Answer

import java.io.BufferedReader;

import java.io.InputStreamReader;


class item

{

String sale, name, description;

int numofitem, price, change,five,ten,totalpaid,totalcost;

}


public class cash {

int one, five, ten;

double total;

public cash(int one, int five, int ten)

{

this.one = one;

this.five = five;

this.ten = ten;

total = one + five*5 + ten*10;

}

public static void main(String args[]) throws Exception

{

int one,five,ten;

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter no of $1 bills: ");

one = Integer.parseInt(br.readLine());

System.out.println("Enter no of $5 bills: ");

five = Integer.parseInt(br.readLine());

System.out.println("Enter no of $10 bills: ");

ten = Integer.parseInt(br.readLine());

cash ob = new cash(one,five,ten);

item arr[] = new item[20];

int i=0, flag=0;


do

{

try

{

arr[i] = new item();

System.out.println("Enter sale: ");

arr[i].sale = br.readLine();

System.out.println("Enter purchaser name: ");

arr[i].name = br.readLine();

System.out.println("Enter item description: ");

arr[i].description = br.readLine();

System.out.println("Enter no of item purchased: ");

arr[i].numofitem = Integer.parseInt(br.readLine());

System.out.println("Enter price for one item $1, $2, $5, $7, $9, or $10: ");

arr[i].price = Integer.parseInt(br.readLine());

arr[i].totalcost = arr[i].numofitem*arr[i].price;

System.out.println("Enter no of $5 bills paid: ");

arr[i].five = Integer.parseInt(br.readLine());

System.out.println("Enter no of $10 bills paid: ");

arr[i].ten = Integer.parseInt(br.readLine());

arr[i].totalpaid = arr[i].five*5 + arr[i].ten*10;

ob.five+=arr[i].five;

ob.ten+=arr[i].ten;

ob.total+=arr[i].totalpaid;

arr[i].change = arr[i].totalpaid-arr[i].totalcost;

ob.total-=arr[i].change;

System.out.println("Enter another item? if yes press 1 else press 0");

flag = Integer.parseInt(br.readLine());

i++;

}

catch(Exception e)

{

}

}while((flag==1)&&(i<20));

for(int j=0;j<i;j++)

{

System.out.println("sale: " + arr[j].sale);

System.out.println("purchaser name: " + arr[j].name);

System.out.println("item description: " + arr[j].description);

System.out.println("no of item purchased: " + arr[j].numofitem);

System.out.println("price for one item: " + arr[j].price);

System.out.println("Total price: " + arr[j].totalcost);

System.out.println("Price user paid: " + arr[j].totalpaid);

System.out.println("change tendered: " + arr[j].change);

int temp = arr[j].change;

if(temp>=10)

{

System.out.println("No of $10 bills in change: " + temp/10);

ob.ten-=temp/10;

temp=temp%10;

}

if(temp>=5)

{

System.out.println("No of $5 bills in change: " + temp/5);

ob.five-=temp/5;

temp=temp%5;

}

if(temp>=1)

{

System.out.println("No of $1 bills in change: " + temp);

ob.one-=temp;

}

System.out.println("Total cost of order: " + arr[j].totalcost);

System.out.println("Total cash in hand: " + ob.total);

System.out.println("Total no of $1 bills: " + ob.one);

System.out.println("Total no of $5 bills: " + ob.five);

System.out.println("Total no of $10 bills: " + ob.ten);

}

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote