Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will practice designing a more complex class, using while loops, using conditionals, using a Scanner object and mathematical expressions. ----------------------------------------------------------- For

In this assignment, you will practice designing a more complex class, using while loops, using conditionals, using a Scanner object and mathematical expressions.

-----------------------------------------------------------

For this assignment, you will write a class for the game Pig. Your file should be called DinnerOutLASTNAME.java where LASTNAME is replaced with your last name (notin all capital letters). Be sure to name your class and constructor according to this file name.

The class will contain the following attributes:

  • n (number of people in the dinner party)
  • person1, person2, person3, person4, person5, person6
  • tax
  • tip
  • amount1, amount2, amount3, amount4, amount5, amount6
  • scan (a Scanner object)

The "person" variables should point to the names of the people in the dinner party and the amounts should correspond to their totals.

The code should do the following:

  1. Ask the user how many people are in the party (if they enter more than 6, let them know 6 is the maximum and set n = 6)
  2. Ask the user to provide names for each person
  3. Ask the user to enter the cost of each item in the bill corresponding to the person. It should allow them to enter as many items as they like. If the user wishes to stop, they can indicate this by entering 0.
  4. Ask the user for the tax
  5. Ask the user for the tip
  6. Display the totals each person owes.

You are allowed to organize your code however you like. The code should have a constructor and as toString() method. The toString method should print out the amounts owed by each member of the dinner party. Attached is a printup of one way this could work.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres an implementation of the Pig class according to your requirements import javautilScanner public class DinnerOutSmith private int n private Strin... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Operations Management

Authors: R. Dan Reid, Nada R. Sanders

4th edition

9780470556702, 470325046, 470556706, 978-0470325049

More Books

Students also viewed these Programming questions

Question

Explain the steps involved in training programmes.

Answered: 1 week ago