# Answered Essay: For this programming assignment, you will copy a program called ExpensePerPerson.java, furnished by the instructor.

For this programming assignment, you will copy a program called ExpensePerPerson.java, furnished by the instructor.
Your task for this program is to try to compile the program, read all of the error messages, and try to find and fix the errors.
After finding the errors, you need to also add the necessary code to calculate average expense per person in a family.
The formula to use is the total expense of family divided by the number of persons in the family.

// ExpensePerPerson.java

// Trine University
// Fall 2017
// CS 1113
// Program 1

// This class takes the input of total expense of a family, and the number of persons in the family
// and then calculate average expense per person of the family.

// Allows us to read in information from the keyboard

import java.util.Scanner;
public class ExpensePerPerson
{
public static void main(String[] args)
{
// Declare all objects

Scanner scan = new Scanner(System.in); // The object that reads in input

// Declare all primitive variables

double expenses, // Total expense of the family
persons; // Total family members

// Prompt user for input
System.out.println(” and the number of persons in the family.”);

// Read in the user input.
expenses = scan.nextDouble();
persons = scan.nextDouble();

//Compute all results
// [Add code here to compute the value of the variable averageExpense.]

//Print all results.
System.out.println(“The average expense per person in the family is : ” + averageExpense);

} // End of main

} // End of class ExpensePerPerson

1. If you wish to copy the program above from the webpage, you can copy it.

2. The file must be named ExpensePerPerson.java, where ExpensePerPerson is the
name of the class in the Java program. Notice that the name of your file is
the same as the name of the class in that file. Throughout the semester, this
will always be the case. Be sure to name your file exactly as it is shown here
(including capitalization). You will lose points
if you name the file incorrectly.

3. You can try to compile the Java program in the file using :

javac ExpensePerPerson.java

This semester we will always compile files with the command:

javac x.java

where you replace x.java with the name of the Java source code file you created
(In program 1, replace x by ExpensePerPerson).

4. The program shown above contains three errors. When you compiled the
program, you should have gotten error messages that tell you where the errors
are. Using the message, correct the errors, save the changed
program.(If you got more than one error message, this indicates
you made errors while typing the program; fix those errors, too.)

Examples of the errors in this program are as follows:

a. A missing semicolon. The following example contains a missing
semicolon at the end of the line:

System.out.println(“hello”)

This could produce an error as follows:

ExpensePerPerson.java:100: ‘;’ expected

b. Missing quotes. For example,

System.out.println(“hello);

This could produce an error as follows along with many other errors:

ExpensePerPerson.java:5: unclosed string literal

c. A declared but undefined variable. For example, the variable below is
used in an assignment statement but it does not have a value.

int a, b;

b = a + 1;

This could produce an error as follows:

ExpensePerPerson.java:7: variable a might not have been initialized

5. Compile the program again.
The program should now compile with no errors.

6. Add the necessary code to calculate the value of averageExpense,
the average expense per person in the family, in the designated area.

7. Recompile the program.

8. Run the Java program by issuing command:

java x

where x is the name of the class in the Java program. The program will
prompt you (that is, ask you) to enter the expense of the family, and
number of people in the family.
Type total expense of the family and hit the “enter” key. Then enter the
number of people in the familyand hit the “enter” key.
The program will print the results of your arithmetic operations on
those numbers.
​(In Java)

import java.util.Scanner;

public class ExpensePerPerson

{

public static void main(String[] args)

{

// Declare all objects

Scanner scan = new Scanner(System.in); // The object that reads in input

// Declare all primitive variables

double expenses, // Total expense of the family

persons, averageExpense; // Total family members

// Prompt user for input

System.out.println(” and the number of persons in the family.”);

// Read in the user input.

expenses = scan.nextDouble();

persons = scan.nextDouble();

//Compute all results

// [Add code here to compute the value of the variable averageExpense.]

averageExpense = expenses/persons;

//Print all results.

System.out.println(“The average expense per person in the family is : ” + averageExpense);

} // End of main

} // End of class ExpensePerPerson

Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.