NEED THIS IN 30 MINUTES PLEASE Java programming: I need some help on this, I hav
ID: 3596688 • Letter: N
Question
NEED THIS IN 30 MINUTES PLEASE
Java programming: I need some help on this, I have include one of my previous assignments below.
1. Create a function/method to read in one of your data items. Nothing will be passed in and the data item will be passed back.
2. create a function/method to perform one of your calculations. You will have to pass all needed data and pass back the resulting value calculated.
3. Create a function/method to do some of the required printing. The values to be printed will be passed in and nothing will be passed back.
Here is my previous assignment PLEASE EDIT IT TO FIT IN WITH THE 3 INSTRUCTIONS ABOVE:
import javax.swing.JOptionPane;
public class Bill
{
public static void main(String[]args)
{
String name, data,output;
double discount, fee, findue, Materials, Total;
int Hours;
//input data
name=JOptionPane.showInputDialog(null, "Construction Firm Name","Input Data",JOptionPane.QUESTION_MESSAGE);
name=JOptionPane.showInputDialog(null,"Customer Name","Input data",JOptionPane.QUESTION_MESSAGE);
data=JOptionPane.showInputDialog(null,"Number of labor hours","Input data",JOptionPane.QUESTION_MESSAGE);
Hours=Integer.parseInt(data);
data=JOptionPane.showInputDialog(null,"Amount of materials","Input data",JOptionPane.QUESTION_MESSAGE);
Materials=Double.parseDouble(data);
//calculations
Total=Hours*50;
fee=Total+Materials;
discount=fee*.10;
findue=fee-discount;
//Print results
System.out.println("Construction Firm Name:"+name+" ");
System.out.println("Customer:"+name+" ");
System.out.println("Number of Hours="+Hours);
System.out.println("Labor="+Hours);
System.out.println("Materials="+Materials);
System.out.println("Job Fee=" +fee);
System.out.println("Discount="+discount+" ");
System.out.println("Final Amount Due="+findue);
System.exit(0);
}
}
Explanation / Answer
import javax.swing.JOptionPane;
public class Bill
{
static String name, data,output;
static double discount, fee, findue, Materials, Total;
static int Hours;
static double[] calcsArray = new double[3];
public static void main(String[]args)
{
//input data
data = processInput();
Materials=Double.parseDouble(data);
//calculations
calcsArray = performCalculations(Hours, Total, Materials, fee);
fee = calcsArray[0];
discount = calcsArray[1];
findue = calcsArray[2];
//Print results
processOutput(name, Hours, Materials, fee, discount, findue);
System.exit(0);
}
//instruction-1
private static String processInput() {
name=JOptionPane.showInputDialog(null, "Construction Firm Name","Input Data",JOptionPane.QUESTION_MESSAGE);
name=JOptionPane.showInputDialog(null,"Customer Name","Input data",JOptionPane.QUESTION_MESSAGE);
data=JOptionPane.showInputDialog(null,"Number of labor hours","Input data",JOptionPane.QUESTION_MESSAGE);
Hours=Integer.parseInt(data);
data=JOptionPane.showInputDialog(null,"Amount of materials","Input data",JOptionPane.QUESTION_MESSAGE);
return data;
}
//instruction-2
private static double[] performCalculations(int Hours, double Total, double Materials, double fee) {
Total=Hours*50;
fee=Total+Materials;
discount=fee*.10;
findue=fee-discount;
calcsArray[0] = fee;
calcsArray[1] = discount;
calcsArray[2] = findue;
return calcsArray;
}
//instruction-3
private static void processOutput(String name, int Hours, double Materials, double fee, double discount, double findue) {
System.out.println("Construction Firm Name:"+name+" ");
System.out.println("Customer:"+name+" ");
System.out.println("Number of Hours="+Hours);
System.out.println("Labor="+Hours);
System.out.println("Materials="+Materials);
System.out.println("Job Fee=" +fee);
System.out.println("Discount="+discount+" ");
System.out.println("Final Amount Due="+findue);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.