Description
How to fix java code?
Problem
Sparky Power works for Shockingly Good Electrical Company. She installs electrical boxes in commercial
buildings. For each building she works in there is a trip charge of $125.00 and an additional charge of $51.00 for each box she installs. We need to write a program that computes the revenue for each month that Ms. Power works. For example, if 937 boxes were installed in 31 buildings Ms. Power would generate $51,662.00.
BEHAVIOR:
The program should display on the screen a prompt for the number of buildings that Ms. Power worked in and the total number electrical boxes that she installed. The user should enter these values from the keyboard. The program should compute and display on the screen the total amount of revenue resulting from these building installations.
Here is the SS of the code so you can see the errors http://prntscr.com/1d2gvg
in writing
import java.util.Scanner;
public class EggBasket2
{
public static void main(String[] args)
{
int buildingNumber, electricalBoxes;
final double BUILDING_CHARGE=125;
final double ELECTRICAL_BOX_COST=51;
double totalRevenue;
double buildingRevenue;
double boxRevenue;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the number of building:");
buildingNumber = keyboard.nextInt( );
System.out.println("Enter the number of electrical boxes:");
electricalBoxes = keyboard.nextInt( );
Compute buildingRevenue= buildingNumber * BUILDING_CHARGE;
Compute boxSum= ELECTRICAL_BOX_COST * electricalBoxes;
Compute total= buildingRevenue + boxRevenue
System.out.println("totalRevenue");
}
}
http://www.nvcc.edu/home/dfranssell/CSC130/week1%20Problem%20lecture%20handout.pdf
Explanation & Answer
Hi there,
please see the corrected code below
import java.util.Scanner;
public class EggBasket2
{
public static void main(String[] args)
{
int buildingNumber, electricalBoxes;
final double BUILDING_CHARGE=125;
final double ELECTRICAL_BOX_COST=51;
double totalRevenue;
double buildingRevenue;
double boxRevenue;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the number of building:");
buildingNumber = keyboard.nextInt( );
System.out.println("Enter the number of electrical boxes:");
electricalBoxes = keyboard.nextInt( );
buildingRevenue= buildingNumber * BUILDING_CHARGE;
boxRevenue= ELECTRICAL_BOX_COST * electricalBoxes;
totalRevenue= buildingRevenue + boxRevenue;
System.out.println("Total Revenue generate :" + totalRevenue);
}
}
Review
Review
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
How to Win Friends and Influence People
by Dale Carnegie
Herzog
by Saul Bellow
The Metamorphosis
by Franz Kafka
Shattered - Inside Hillary Clintons Doomed Campaign
by Amie Parnes and Jonathan Allen
The Aftermath
by Rhidian Brook
The Eyes Were Watching God
by Zora Neale Hurston
Where'd You Go Bernadette
by Maria Semple
And Then There Were None
by Agatha Christie