# (Solved Homework): 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

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): For this programming assignment, you will copy a program called ExpensePerPerson.java, furnished by the instructor….
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!

// 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: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

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.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.