1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maks197457 [2]
3 years ago
12

You are working as the IT support person for an electrician. The electrician has asked you to create a program that generates a

report to show the month’s customers, the total number of customers, and the amount owed across all customers. Each customer record contains a customer number, customer name, number of kilowatt hours used (up to, but not including 1000.0) and the amount owed. The amount owed is based on the number of kilowatt hours used based on the following rate schedule: Number of Kilowatts Used Cost 0.0 -199.9 $0.11 per kilowatt 200.0+ $0.08 per kilowatt Your program should gather the input data from the user. Then your program should calculate and print the each customer’s record and amount owed on a weekly payroll report. All input data and calculated amounts should appear on the report. The total amount owed and total number of customers should appear at the end of the report. When there are no customers, an error message should appear instead of a report. You may assume the customer number and customer name have already been validated and will never included an empty value.
Computers and Technology
1 answer:
Alexus [3.1K]3 years ago
7 0

Answer:

Customer.java

public class Customer {

private int customerNo;

private String customerName;

private double kwhourconsumed;

private double amountowed;

public int getCustomerNo() {

return customerNo;

}

public void setCustomerNo(int customerNo) {

this.customerNo = customerNo;

}

public String getCustomerName() {

return customerName;

}

public void setCustomerName(String customerName) {

this.customerName = customerName;

}

public double getKwhourconsumed() {

return kwhourconsumed;

}

public void setKwhourconsumed(double kwhourconsumed) {

this.kwhourconsumed = kwhourconsumed;

}

public double getAmountowed() {

return amountowed;

}

public void setAmountowed(double amountowed) {

this.amountowed = amountowed;

}

Override

public String toString() {return "Customer [customerNo=" + customerNo + ", customerName=" + customerName + ", kwhourconsumed="  + kwhourconsumed + ", amountowed=" + amountowed + "]";

}

}

PayrollReport.java

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class PayrollReport {

public static Customer getCustomerDetails(Scanner sc)

{

Customer cust= new Customer();

System.out.println("Enter Customer Number");

int customerNo=sc.nextInt();

cust.setCustomerNo(customerNo);

System.out.println("Enter Customer Name");

String customerName=sc.next();

cust.setCustomerName(customerName);

System.out.println("Enter Customer kilowatt hours used");

double kwhourconsumed=sc.nextDouble();

cust.setKwhourconsumed(kwhourconsumed);

return cust;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in); //Used Scanner Class to take Input from User

//List to add all the customer details

//Customer POJO is created so that multiple Objects can be stored

List<Customer> list= new ArrayList<Customer>();

//User shoud Enter Y to add more customer details and N to stop Entering

while(true)

{

//Method to Input Customer Details

Customer cust=getCustomerDetails(sc);

//Getting back the object and setting to the list

list.add(cust);

System.out.println("To Add more customer Enter 'Y' or Else 'N'");

String yn=sc.next();

if(yn.equals("Y"))

continue;

else

break;

}

sc.close();

double amountOwed=0.0;

for(int i=0;i<list.size();i++)

{

double hrconsumed=list.get(i).getKwhourconsumed();

if(hrconsumed>0.0 && hrconsumed<=199.9)

{

amountOwed=(hrconsumed*0.11);

list.get(i).setAmountowed(amountOwed);}

else if(hrconsumed>= 200.0)

{

amountOwed=(double)(199.99*0.11)+(hrconsumed-200.0)*0.08;

list.get(i).setAmountowed(amountOwed);

}

}System.out.println("///////////////////////////");

System.out.println("Weekly Payroll Report");

double totalamountowed=0.0;

for(int i=0;i<list.size();i++)

{

System.out.println("CUSTOMER - "+i+1);

System.out.println("Customer No- "+list.get(i).getCustomerNo());

System.out.println("Customer Name- "+list.get(i).getCustomerName());

System.out.println("Customer kilowatt hours used

"+list.get(i).getKwhourconsumed());

System.out.println("Customer amount owed in $- "+list.get(i).getAmountowed());

totalamountowed=totalamountowed+list.get(i).getAmountowed();

}

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

System.out.println("END Report");

System.out.println("Total Number of Customer "+list.size());

System.out.println("Total Amount Owed In $ "+totalamountowed);

}

}

Explanation:

Made some modifications for clarity and simplicity.

You might be interested in
Do you need a contractor to install nest thermostat
Natalka [10]

Answer:

Sometimes yes, sometimes you can do it yourself

Explanation:

Installing a Nest thermostat can be done yourself without an electrician in most cases. Nest thermostats are designed to work in homes without a common (“C”) wire. However, there are rare cases a C wire or other power-supply accessory may be required. An electrician is recommended in these rare cases.

5 0
3 years ago
What function would you use to calculate the total interest paid for the first year of a mortgage?.
WITCHER [35]

Answer:

To calculate the total interest paid for the first year of a mortgage, the formula M = [P.r (1+r)n] / [(1+r)n-1] × 12 can be used.

Explanation:

3 0
2 years ago
The “Fix a Problem” section of About.com’s PC support page provides information on Reversing Damages and (blank) plss help its t
Lera25 [3.4K]

Answer:

Mistakes

Explanation:

What are the three main technical support options for Microsoft users. Find It Myself, Ask the Community, <u>The "Fix a Problem" section of About.com's PC support page provides information on Reversing Damages and </u><u>MISTAKES.</u>

4 0
3 years ago
Read 2 more answers
Which of the following enables robots to do things such as understand itself, walk, talk, and develop skills?
zmey [24]

Answer:

self-modeling

Explanation:

Robots, which are man-made machines which mimics the actions of man like walking, talking, rendering assistance are part of the future plans to make the society easier. It was mans' attempt to improve the society but still happens to be work in progress.

For the robots to be able to carryout its function, there is need for it to be self modelling in the sense of initiating and executing the commands which was already programmed into it. <em>For example, telling it to walk will be initiated by him as a command, after processing the command, it will execute it without any other information.</em>

7 0
3 years ago
List three reasons you might use hwinfo when troubleshooting and upgrading a computer
Elza [17]

Solution:

three reasons you might use hwinfo when troubleshooting and upgrading a computer are as follows:

1) If we want to identify a hardware component with out opening the case.

2. if we want identify Features of a motherboard, video card, or processor.

3. establish benchmarks for the components in

8 0
3 years ago
Other questions:
  • 2. a. Write pseudocode for a divide-and-conquer algorithm for finding valuesof both the largest and smallest elements in an arra
    11·1 answer
  • Scientific models can be used for a variety of different purposes. Which of the following statements about scientific models is
    7·2 answers
  • The while loop is a pre-test loop? TRUE OR FALSE
    9·2 answers
  • Basics AutoCare is a small auto service business with two locations in a Midwest (U.S.) city. The business is based on providing
    13·1 answer
  • You can minimize the Ribbon with a command contained on the _____.
    7·1 answer
  • White lines
    7·2 answers
  • DECIPHER AND SOLVE THIS<br><br> SCC:R<br> D<br> YJOTE VP=GPIMFRT
    15·1 answer
  • What type of block start a sequence?
    12·1 answer
  • Please answer fast computer picture above​
    14·1 answer
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!