Question: Chegg I need your help, below are the comments from my professor in regards to my code for the main class and subclass. I need

Chegg I need your help, below are the comments from my professor in regards to my code for the main class and subclass. I need someone to help me rework my main class, and my subclass so I can submit the info in my Netbeans, and ultimately back to my instructor for review.

Instructor Comments Below

You have a lot of issues in this one. I can't really begin to list them all. There should never be a "main" in the subclass for one thing and the subclass should be rather small.

I'm just going to attach the s-code for this one. It should help you form the code. Also, do not deviate from the name convention.

Below in BOLD is the Main Class Skelton or S-Code the instructor wants us to use to create the code.

week09_skeleton.java

package week09_skeleton;

/**

* @Course: SDEV 250 ~ Java Programming I

* @Author Name:

* @Assignment Name: week09_skeleton

* @Date: Nov 5, 2016

* @Description: Week 9 Skeleton Code

*/

//Imports

import java.util.Scanner;

//Begin Class Week09_Skeleton

public class Week09_Skeleton {

//Begin Main Method

public static void main(String[] args) {

//Declarations

double prevRead;

double curRead;

String runAgain;

//New Scanner object

Scanner sc = new Scanner(System.in);

System.out.println("Welcome to the City Power Bill Calculator!");

//Begin do loop

do {

System.out.print("Please enter your previous meter reading: ");

prevRead = sc.nextDouble();

System.out.print("Please enter your current meter reading: ");

curRead = sc.nextDouble();

/**

* Instantiate a new subclass object and send the previous and

* current readings to the new object (all in one line)

*/

//Declare new instance of the subclass here

/**

* Output all results using formatted output. Call each get method

* to get the data.

*/

//Your usage was: " call get method

//Your rate was: " call get method

//Your subtotal is: " call get method

//Taxes are: " call get method

//Your total bill this month is: " call get method

System.out.print(" Would you like to Calculate a new usage? "

+ "(Y for Yes, N to exit): ");

runAgain = sc.next();

} while (runAgain.equalsIgnoreCase("Y")); //End do loop

System.out.println(" Thank you for using this program. Goodbye!");

} //End Main Method

} //End Class Week09_Skeleton

Below in BOLD is the SubClass Skelton or S-Code the instructor wants us to use to create the code.

MyUtility.java

package week09_skeleton;

/**

* @Course: SDEV 250 ~ Java Programming I

* @Author Name:

* @Assignment Name: week09_skeleton

* @Date: Nov 5, 2016

* @Subclass MyUtility Description: Week 9 Skeleton subclass

*/

//Imports

//Begin Subclass MyUtility

public class MyUtility {

//Declarations

private double usage;

private double subTot;

private double tax;

private double bill;

private double rate;

//Final declarations

private final double RATE_A = 0.0809;

private final double RATE_B = 0.091;

private final double RATE_C = 0.109;

private final double UTIL_TX = .0346;

/**

* Constructor receives values from main class then send them to setUsage

*/

/**

* Default constructor uses 'this' keyword to set default values for the

* variables

*/

//Set Methods***************************************************************

/**

* Set usage is private and receives two parameters. Computes the usage

* sends value to set rate method

*/

/**

* Set rate is private and receives one parameter which is used to determine

* which rate to assign the customer's bill.

* Determines the rate and assigns the corresponding variable declared up top

* Calls set subtotal method and sends rate and usage along.

*/

/**

* Set subtotal is private and receives two parameters which are used to determine

* the customer's subtotal

* Calls set tax method and sends subtotal result along with it.

*/

/**

* Set tax is private and receives one parameter which is used to determine

* the customer's usage tax

* Calls set final method and sends subtotal and tax along with it.

*/

/**

* Set final is private and receives two parameters which are used to determine

* the final bill for the customer

* There is no calling method from this one.

*/

//Get Methods***************************************************************

/**

* Get methods should be public and all should be of a certain type so they

* must return a value. Get methods simply return a value and nothing else.

*/

//Get Methods should be written for:

//return usage

//return rate;

//return subTot

//return tax;

//return bill;

} //End Subclass MyUtility

Below Using Netbeans is the Main Class code I submitted in BOLD, but our instructor wants us to use his S-Code to create our code

package jwabby_week9_classes_and_objects;

/**

* @Course: SDEV 250 ~ Java Programming I

* @Author Name: Justin Wabby

* @Assignment Name: jwabby_week9_classes_and_objects

* @Date: Jul 16, 2017

* @Description: jwabby Week9 Assignment Classes and Objects

*/

//Imports

import java.text.DecimalFormat;

import java.util.Scanner;

//Begin Class Jwabby_Week9_Classes_and_Objects

public class jwabby_Week9_Classes_and_Obects {

//Begin Main Method

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

DecimalFormat df = new DecimalFormat("0.00"); //decimal format

String ch;

double rate = 0;

System.out.println("Welcome to The City Power Bill Calculator");

//loop to calculate the bill

do {

double subtotal = 0;

//get the user input

System.out.println("Please Enter Your Previous meter Reading:");

double prev = sc.nextDouble();

System.out.println("Please Enter Your Current meter Reading:");

double current = sc.nextDouble();

//call the usage function

double usage = MyUsage(prev, current);

//as per usage , fix the rate

if (usage <= 500) {

rate = 0.0809;

} else if (usage > 500 && usage <= 900) {

rate = 0.091;

} else if (usage > 900) {

rate = 0.109;

}

//call the subTot function

subtotal = subTot(usage, rate);

double tax = taxAmount(subtotal); //call taxAmount function

double total_bill = subtotal + tax; //call the subtotal function

//print the output

System.out.println("Your Usage was: " + Float.parseFloat(df.format(usage)) + " KwHs");

System.out.println("Your Rate was: $" + rate + "/KwH");

System.out.println("Your Sub-Total was:$" + Float.parseFloat(df.format(subtotal)));

System.out.println("Taxes are $" + Float.parseFloat(df.format(tax)));

System.out.println("Your total bill this month is:$" + Float.parseFloat(df.format(total_bill)));

System.out.println("Would you like to calculate new Usage(y for yes N for No)");

ch = sc.next();

} while (ch.equalsIgnoreCase("Y")); //check for the choice to continue

sc.close();

System.out.println("Thank you for using the program Goodbye.");

}

//calculate the usage and return the value

private static double MyUsage(double prev, double current) {

return (current - prev);

}

//calculate the sub total and return the value

private static double subTot(double usage, double rate) {

return (usage * rate);

}

//calculate the taxamount and return the value

private static double taxAmount(double subtotal) {

return ((subtotal * 3.46) / 100);

} //End Main Method

} //End Class Jwabby_Week9_Classes_and_Objects

Using Netbeans below is the Subclass I submitted in BOLD, but our instructor wants us to use his S-Code to create our code.

package jwabby_week9_classes_and_objects;

/**

* @Course: SDEV 250 ~ Java Programming I

* @Author Name: Justin Wabby

* @Assignment Name: jwabby_week9_classes_and_objects

* @Date: Jul 16, 2017

* @Description: jwabby Week9 Assignment Classes and Objects

*/

//Imports

import java.text.DecimalFormat;

import java.util.Scanner;

//Begin Class Jwabby_Week9_Classes_and_Objects

public class jwabby_Week9_Classes_and_Obects {

//Begin Main Method

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

DecimalFormat df = new DecimalFormat("0.00"); //decimal format

String ch;

double rate = 0;

System.out.println("Welcome to The City Power Bill Calculator");

//loop to calculate the bill

do {

double subtotal = 0;

//get the user input

System.out.println("Please Enter Your Previous meter Reading:");

double prev = sc.nextDouble();

System.out.println("Please Enter Your Current meter Reading:");

double current = sc.nextDouble();

//call the usage function

double usage = MyUsage(prev, current);

//as per usage , fix the rate

if (usage <= 500) {

rate = 0.0809;

} else if (usage > 500 && usage <= 900) {

rate = 0.091;

} else if (usage > 900) {

rate = 0.109;

}

//call the subTot function

subtotal = subTot(usage, rate);

double tax = taxAmount(subtotal); //call taxAmount function

double total_bill = subtotal + tax; //call the subtotal function

//print the output

System.out.println("Your Usage was: " + Float.parseFloat(df.format(usage)) + " KwHs");

System.out.println("Your Rate was: $" + rate + "/KwH");

System.out.println("Your Sub-Total was:$" + Float.parseFloat(df.format(subtotal)));

System.out.println("Taxes are $" + Float.parseFloat(df.format(tax)));

System.out.println("Your total bill this month is:$" + Float.parseFloat(df.format(total_bill)));

System.out.println("Would you like to calculate new Usage(y for yes N for No)");

ch = sc.next();

} while (ch.equalsIgnoreCase("Y")); //check for the choice to continue

sc.close();

System.out.println("Thank you for using the program Goodbye.");

}

//calculate the usage and return the value

private static double MyUsage(double prev, double current) {

return (current - prev);

}

//calculate the sub total and return the value

private static double subTot(double usage, double rate) {

return (usage * rate);

}

//calculate the taxamount and return the value

private static double taxAmount(double subtotal) {

return ((subtotal * 3.46) / 100);

} //End Main Method

} //End Class Jwabby_Week9_Classes_and_Objects

Here is the information I used to create my code. This week, you will update your week 6 program and implement a subclass to handle the calculations.

The local power company has decided that in order to better serve their customers and encourage power savings, they will charge their customers based upon their power consumption each month. In doing so, they have asked your software company to make a simple online application that their customers can run in order to get an idea how much their bills may be for the month.

My Cheggs expets I need to create a separate MyUtility subclass code and a seperate main class, RATE and Variables should be private to the subclass.

Write a program that will ask for the customers last and current meter reading in Kilowatt Hours (KwHs). Determine the amount of usage for the month and calculate a sub total (before tax) and a total amount due (tax included) using the following constraints.

Constraints

Rate A: For 500 KwHs or less = $0.0809 / KwH

Rate B: For 501 to 900 KwHs = $0.091 / KwH

Rate C: For greater than 900 KwHs = $0.109 / KwH

Utilities Tax is 3.46% regardless of usage.

Requirements

Create a separate (external to the main class) subclass MyUtility() Rate and tax variables should be private to the subclass.

Use a constructor to initialize the default reading values to 0

Use another constructor to set the reading values

Use set and get methods in MyUtility() to determine the usage, rate, subtotal, tax, and final bill

Format all output as follows:

Usage to 1 decimal place, KhWs

Rate to 4 decimal places, monetary

Subtotal to 2 decimal places, monetary

Taxes to 2 decimal places, monetary

Total to 2 decimal places, monetary

Implement a loop to return and enter new values (run the program again) if the user wishes to

Hints

Set methods can do all the computation

Set methods can call other set methods

The type of loop can be of your choosing

Make sure you use Java coding conventions

Expected Output

Below is a sample run with three iterations. User input is in BOLD.

Welcome to the City Power Bill Calculator!

Please enter your previous meter reading: 750

Please enter your current meter reading: 1250

Your usage was: 500.0 KwHs

Your rate was: $0.0809/KwH

Your subtotal is: $40.45

Taxes are: $1.40

Your total bill this month is: $41.85

Would you like to calculate a new usage?

(Y for Yes, N to exit): y

Please enter your previous meter reading: 750

Please enter your current meter reading: 1350.63

Your usage was: 600.6 KwHs

Your rate was: $0.0910/KwH

Your subtotal is: $54.66

Taxes are: $1.89

Your total bill this month is: $56.55

Would you like to calculate a new usage?

(Y for Yes, N to exit): y

Please enter your previous meter reading: 750.39

Please enter your current meter reading: 1655.37

Your usage was: 905.0 KwHs

Your rate was: $0.1090/KwH

Your subtotal is: $98.64

Taxes are: $3.41

Your total bill this month is: $102.06

Would you like to calculate a new usage?

(Y for Yes, N to exit): n

Thank you for using this program. Goodbye!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!