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

A software company sells a package for different prices and offer discounts depe

ID: 3778728 • Letter: A

Question

A software company sells a package for different prices and offer discounts depending on the type of purchase. You can download the software from their website. Write a class called SoftwareSales.java that stores the type of purchase and quantity. The class has a method called calculate Total Cost() that returns the total cost of the purchase. Write a driver file called SoftwareSalesDemo.java that asks the user to enter the type of purchase. The program should display the total cost of the purchase. Welcome to Software Sales: Student Academic (Faculty) Commercial Enter the type of purchase: 2 [Enter] Enter the quantity: 2 [Enter] Total cost of purchase: $338.30

Explanation / Answer

SoftwareSales.java

------------------------------


public class SoftwareSales {
   private int[] prices;
   private int[] discnt;
  
   public int[] getPrices() {
       return prices;
   }
   public void setPrices(int[] prices) {
       this.prices = prices;
   }
   public int[] getDiscnt() {
       return discnt;
   }
   public void setDiscnt(int[] discnt) {
       this.discnt = discnt;
   }
   public SoftwareSales() {
       super();
       this.prices = new int[]{99,199,299};
       this.discnt = new int[]{20,15,10};
   }
  
   public double calculateTotalCost(int choice, int qty) {
       int totalSum=prices[choice-1]*qty;
       return (double)totalSum*(100-discnt[choice-1])/100;
   }
  
}

SofwareSalesDemo.java

----------------------------------

import java.util.Scanner;


public class SoftwareSalesDemo {

   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       int choice,qty;
       SoftwareSales ss=new SoftwareSales();
      
       System.out.println("Welcome to Sofware Sales:");
       System.out.println("1) Student 2) Academic (Faculty) 3) Commercial");
       System.out.println("Enter the type of purchase: ");
       choice=in.nextInt();
       System.out.println("Enter the quantity: ");
       qty=in.nextInt();
       System.out.println(" Total cost of purchase: $"+ss.calculateTotalCost(choice, qty));

   }

}

OUTPUT:

Welcome to Sofware Sales:
1) Student
2) Academic (Faculty)
3) Commercial
Enter the type of purchase:
2
Enter the quantity:
2

Total cost of purchase: $338.3

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