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

You are asked to create a receipt generation module for your company’s Point of

ID: 3742335 • Letter: Y

Question

You are asked to create a receipt generation module for your company’s Point of Sale software.

The receipt will consist of heading lines, then one line per product sold, and then several summary lines giving the total price, GST, and change calculation. The lines will be 40 characters long.

For each item sold, you will ask the user three questions: The name of the item, the quantity sold, and the unit price. If the name of the item is empty (the user just presses Enter) it means there are no more items and you will instead ask the user for the amount of cash paid, and then finish the receipt.

To simplify the scenario (because weeks 1–5 of the course do not cover storage of data in the computer’s memory) we will ask for the information progressively, and print the information as it is received. Note that the total and GST lines will be printed before asking for the amount of cash paid.

The formatting of the receipt must be as follows:

The first heading line has to say ‘WELCOME TO MY STORE’ on the left, then spaces, then ‘TAX INVOICE’ on the right. The second heading line has to say ‘ABN 00 000 000 000’.

There must be a blank line between the heading lines and the items.

The item lines must have 25 columns for the item name, 5 columns for the quantity sold (an integer) and 10 columns for the line price (the quantity times the unit price; with two decimal places). The item name must be printed in uppercase.

There must be a blank line between the items and the summary lines.

The summary lines must be, in order: (i) ‘TOTAL’ in 30 columns followed by the total in 10 columns (with two decimal places), and similarly for (ii) ‘GST INCLUDED IN TOTAL’, (iii) ‘CASH PAID’ and (iv) ‘CHANGE’. The GST included in the total is calculated by dividing the total by 11.

Explanation / Answer


package GCDDemo;

import java.util.Scanner;

public class Sales {

static Scanner sc=new Scanner(System.in);
static char charName[][]=new char[1][25];
static char charQuantity[][]=new char[1][5];
static char charUnit[][]=new char[1][10];
static double price=0,GST=0,cash=0,change=0,total=0;
static String name,Quantity,UnitPrice;
public static void main(String args[])
{
getProductInfo();
fixIntoVariable();
cal();
System.out.println("WELCOME TO MY STORE"+" "+"TAX INVOICE");
System.out.println();
System.out.println("ABN 00 000 000 000");
System.out.println();
System.out.println("Item Name"+" "+"Quantity"+" "+"Unit Price");
System.out.println();
System.out.println("Total"+" "+"GST INCLUDED IN TOTAL"+" "+"CASH PAID"+" "+"CHANGE");
System.out.println();
System.out.println("Enter the Amount to be paid");
double paidnn=sc.nextDouble();
System.out.println(total+" "+GST+" "+paidnn+" "+(paidnn-total));
  
  
}
public static void getProductInfo()
{
System.out.println("Enter the Name of the item:");
name=sc.next();
if(!name.equals(""))
{
System.out.println("Enter the Quantity of the item:");
Quantity=sc.next();
System.out.println("Enter the Unit Price of the item:");
UnitPrice=sc.next();
}
else
{
System.exit(0);
}
  
}
public static void fixIntoVariable()
{
int len=name.length();
int valen=25-len;
int i=0;
for(i=0;i<valen;i++)
{
charName[0][i]=' ';
  
  
}
for(;i<25;i++)
{
charName[0][i]=name.charAt(i);
}
  
len=Quantity.length();
valen=5-len;
for(i=0;i<valen;i++)
{
charQuantity[0][i]='0';
}
for(;i<5;i++)
{
charQuantity[0][i]=Quantity.charAt(i);
}
len=UnitPrice.length();
valen=10-len;
for(i=0;i<valen;i++)
{
charUnit[0][i]='0';
}
for(;i<10;i++)
{
charUnit[0][i]=UnitPrice.charAt(i);
}
}
public static void cal()
{
price=Double.parseDouble(Quantity)*Double.parseDouble(UnitPrice);
GST=0.10*Double.parseDouble(Quantity);
total=price+GST;
}
  
  
  
}
  

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