In java jGrasp a program that keeps track of sales and returns are recorded. Sal
ID: 3811124 • Letter: I
Question
In java jGrasp a program that keeps track of sales and returns are recorded. Sale, transactions in a large department store. Both inheritance Return are used in the program, related in the following Transaction The Transaction class is defined below publie elaas Transact tion private string myDeacription: private int e myrt Public static final double Tax RA -0.07 //constructor pubiie Transactions (string deacription, int numrtens. double itencea t) my Description deacription public string getDescription return myneseriptioni lie int geeNumIeeman CJ return Nun Items a publie double getrtemoost return myitemoos e getTotal public double cost myNumrtemB double tax cost TAX RATE return cost tax (a) Write the code for the sale class. Each sale includes v. A description of the item being sold. The number of the items being sold The cost of this item Whether the sale is cash or credit, stored as a boolean variable A 10 percent discount for cash with 10 percent stored as a final variable When a new sale is created, it must be assigned an item description, the number being sold, the cost of this item, and whether the sale is cash or credit. Operations on a sale include the following: Retrieve the description of the item being sold. Scanner Retrieve the quantity of the item being sold. Retrieve the cost of the item being sold. Retrieve whether the sale is cash or credit. Calculate the total for the sale. In calculating this total, a 10% discount for paying cash should be applied to the cost before the tax is calculated.Explanation / Answer
ANSWER:::
import java.util.Scanner;
public class Sales
{
public static void main(String[] args)
{
final int SALESPEOPLE = 5;
int[] sales = new int[SALESPEOPLE];
int sum;
Scanner scan = new Scanner(System.in);
for (int i=0; i<sales.length; i++)
{
System.out.print("Enter sales for salesperson " + (i+1) + ": ");
sales[i] = scan.nextInt();
}
System.out.println(" Salesperson Sales");
System.out.println("--------------------");
sum = 0;
int maximum = sales[0];
int minimum = sales[0];
int a=1, b=1;
for (int i=0; i<sales.length; i++)
{
if(maximum < sales[i])
{
maximum = sales[i];
a = i+1;
}
if(minimum > sales[i])
{
minimum = sales[i];
b = i+1;
}
System.out.println(" " + (i+1) + " " + sales[i]);
sum += sales[i];
}
System.out.println(" Total sales: " + sum);
System.out.println("The average sale is: " + sum / SALESPEOPLE );
System.out.println("The maximum sale is: " + maximum + " by Salesperson " + a );
System.out.println("The minimum sale is: " + minimum + " by Salesperson " + b );
int number;
System.out.println("Enter a number");
number = scan.nextInt();
System.out.println("The number you entered is " +number);
System.out.println(sales);
for (int i=0; number<i; i++)
{
System.out.println(+ sales[i]);
}
}
}
public class RetailItem
{
private String description;
private int unitsOnHand;
private double price;
public RetailItem()
{
description = " ";
unitsOnHand = 0;
price = 0.00;
}
public RetailItem(String description, int unitsOnHand, double price)
{
setDescription(description);
setUnitsOnHand(unitsOnHand);
setPrice(price);
}
public void setDescription(String unitDescription)
{
description = unitDescription;
}
public void setUnitsOnHand(int units)
{
unitsOnHand = units;
}
public void setPrice(double thePrice)
{
price = thePrice;
}
public String getDescription()
{
return description;
}
public int getUnitsOnHand()
{
return unitsOnHand;
}
public double getPrice()
{
return price;
}
public String toString()
{
return "Items Sold: ";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.