You will very soon be the honor of a clothing Store called Sexy. You role will b
ID: 3885590 • Letter: Y
Question
You will very soon be the honor of a clothing Store called Sexy. You role will be to build a data definition class (Construction, getters, setters and specials purpose method). The program will ask you for the name of the store, the number of employees you want to have (If no employees information is entered, the program will set the default number of employees to 20). Also the program will continuously ask you for the amount of sale until you tell the program that you do not wish to enter more sale amount. Also, you program should be able to track the number of sale. At the end, the program will print a well formatted note with the name of the restaurant, the number of employees, the total amount of sales and the number of sales.
Explanation / Answer
import java.util.Scanner;
public class Store {
private String storeName;
private int noOfEmployees;
private Double totalAmountOfSales;
private int totalNoOfSales;
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public int getNoOfEmployees() {
return noOfEmployees;
}
public void setNoOfEmployees(int noOfEmployees) {
if(noOfEmployees==0) this.noOfEmployees = 20;
else this.noOfEmployees = noOfEmployees;
}
public Double getTotalAmountOfSales() {
return totalAmountOfSales;
}
public void setTotalAmountOfSales(Double totalAmountOfSales) {
this.totalAmountOfSales = totalAmountOfSales;
}
public int getTotalNoOfSales() {
return totalNoOfSales;
}
public void setTotalNoOfSales(int totalNoOfSales) {
this.totalNoOfSales = totalNoOfSales;
}
public Store(){
}
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
Store store=new Store();
System.out.println("Enter Name of the Clothing Store:");
store.storeName=scn.next();
System.out.println("Enter Number of Employees:");
store.setNoOfEmployees(scn.nextInt());
double sales_amount=0l;
int sale_count=0;
String ch=null;
do
{
System.out.println("Enter the sales Amount:");
sales_amount+=scn.nextDouble();
sale_count++;
System.out.println("you do not wish to enter more sale amount");
System.out.println("Please Enter N/n");
ch=scn.next();
}while(!ch.equalsIgnoreCase("n"));
store.setTotalAmountOfSales(sales_amount);
store.setTotalNoOfSales(sale_count);
System.out.println("Name of the Store : "+ store.getStoreName());
System.out.println("No of Employees : "+store.getNoOfEmployees());
System.out.println("Total Amount of the sales : "+store.getTotalAmountOfSales());
System.out.println("Total No of the Sales : "+store.getTotalNoOfSales());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.