Question

(Java) Please include one data type class and one driver class in the program. Please also include a UML diagram and pseudocode.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Vendor.java

import java.util.Scanner;

public class Vendor {

//Declaring instance variables

private String id;

private String name;

private double saleAmount;

private double baseSalary;

private double commission;

private double bonus;

//Zero argumented constructor

public Vendor() {

}

//Parameterized constructor

public Vendor(String id, String name, double saleAmount) {

this.id = id;

this.name = name;

this.saleAmount = saleAmount;

}

// getters and setters

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getSaleAmount() {

return saleAmount;

}

public void setSaleAmount(double saleAmount) {

this.saleAmount = saleAmount;

}

//This function will read the data entered by the user

public void readData()

{

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

System.out.print("Enter Name :");

this.name = sc.nextLine();

System.out.print("Enter Id :");

this.id = sc.next();

System.out.print("Enter Total Sale :");

this.saleAmount = sc.nextDouble();

}

//This function will perform calculations and display the vendor data

public void displayVendorInfo() {

// calculating the basesalary,commisssion,bonus

if (saleAmount >= 0 && saleAmount < 20000) {

baseSalary = 2500;

commission = 0;

bonus = 0;

} else if (saleAmount >= 20000 && saleAmount < 30000) {

baseSalary = 2500;

commission = 0.035 * (saleAmount - 20000);

bonus = 0;

} else if (saleAmount >= 30000) {

baseSalary = 2500;

commission = 0.042 * (saleAmount - 20000);

bonus = 0.02 * (saleAmount - 30000);

}

// calculating the total Amount

double totAmt = baseSalary + commission + bonus;

System.out.println("\n\n------------------------");

System.out.println("Vendor Name:\t" + name);

System.out.println("Vendor ID:\t" + id);

System.out.println("Total Sale:\t" + saleAmount);

System.out.println("Base Salary:\t" + baseSalary);

System.out.printf("Commission:\t%.2f\n",commission);

System.out.printf("Bonus:\t\t%.2f\n",bonus);

System.out.printf("Total Amount:\t%.2f\n",totAmt);

System.out.println("------------------------");

}

}

________________

Test.java

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

//Creating an instance of Vendor class

Vendor v = new Vendor();

//calling the methods on the Vendor class

v.readData();

v.displayVendorInfo();

}

}

_________________

Output:

Enter Name :Kane Williams

Enter Id :12345

Enter Total Sale :32254

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

Vendor Name: Kane Williams

Vendor ID: 12345

Total Sale: 32254.0

Base Salary: 2500.0

Commission: 514.67

Bonus: 45.08

Total Amount: 3059.75

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

________________Thank You

Add a comment
Know the answer?
Add Answer to:
(Java) Please include one data type class and one driver class in the program. Please also...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PART2 - Requirement Create the project SP2019LAB4_yourLastName Add one data type class named Representative_yourLastname AND a...

    PART2 - Requirement Create the project SP2019LAB4_yourLastName Add one data type class named Representative_yourLastname AND a driver class named MonthlySalarySlip Class Representative_yourLastName hold some information of the sale representative that includes: name (String), employeeld (String), workCount (int) is the number of appointments he made, and the sale amount (float). The base salary, commission, bonus, salary should be calculated in this class and the method toString will prepare the output The company Kitchen Products produces some good products for the kitchen....

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to...

    DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to be DataSetEmployee. DataSetEmployee should extend ArrayList<Employee> and have no instance variables. You'll have to decide what replaces the getPages concept for getMax/getMin. As a hint, what method of Employee returns a numeric value? Make a package com.acme.midmanager. This package should contain the Manager class. Make a package com.acme.personnel. This package should contain the DataSetEmployee class. Make a package com.acme.topmanagement. This package should contain the...

  • I really need help with this, please. This is a java programming assignment. Project 1 The first programming project inv...

    I really need help with this, please. This is a java programming assignment. Project 1 The first programming project involves writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes. 1. The first class is the Employee class, which contains the employee's name and monthly salary, which is specified in whole dollars. It should have three methods: a. A constructor that allows the name and monthly salary to be...

  • In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of...

    In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of an account such as accountNumber (String), name (String), address (String), balance (float), interestRate(float) and beside the no-argument constructor, parameterized constructor, the class has method openNewAccount, method checkCurrentBalance, method deposit, method withdrawal, method changeInterestRate REQUIREMENT - DRIVER CLASS Provide the application for the Bank Service that first displays the following menu to allow users to select one task to work on. After finishing one task,...

  • For this Java program I have to be implementing a Pedometer class. The driver file will...

    For this Java program I have to be implementing a Pedometer class. The driver file will be provided for you ( PedometerDriver.java ) and can be downloaded in Canvas. Write a stand alone class. Name your class Pedometer and source file Pedometer.java . Program 6 Overview Goals Class and File Naming Here is the Unified Modeling Language (UML) diagram for the Pedometer class. See the end of this document for information on how to read a UML document. Pedometer -...

  • THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following...

    THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following members: -Data Members a)Name of depositor-Stringb)Account Number –intc)Type of account –Boolean d)Balance amount -doublee)AnnualInterestrate -double Methods: -(a)To assign initial values (use constructor)(b)To deposit an amount.(c)TO withdraw amount with the restriction the minimum balance is 50 rs. Ifyouwithdraw amount reduced the balance below 50 then print the error message.(d)Display the name and balance of the account.(e)Get_Monthly_intrestRate() -Return the monthly interestrate whichis nothing but Annualintrestrate/12. Annualinterestrate...

  • Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is...

    Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...

  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

  • Please provide the code for the last part(client side program). yes i have all the class...

    Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT