Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CSCI 1110 – Fall 2021

Assignment 0


The purpose of this assignment is to allow you to self-assess your readiness for this course. If you are struggling to complete this assignment and have not taken CSCI 1100 or CSCI 1105, please consider taking CSCI 1105 before this course. This assignment may be done in any programming language.

For this problem, you will be provided with sample inputs and corresponding outputs. All input is done via the console (unless specified otherwise), and all output is to be done to the console as well. If you are submitting your assignment via Mimir, you can test it by clicking the Run Tests button.

If you are using a language not supported by Mimir, a zip file containing the test inputs and outputs is provided for testing your program.

Please note that unlike the rest of the assignments in this course, this assignment is strictly graded based on functionality. This ensures that you receive the appropriate feedback to decide if CSCI 1110 is the right course for you.

To complete this assignment, you will need to know about:

● Data types

● Variables

● Arithmetic

● Input and Output

● Methods

● 1D or 2D Arrays

In A0, you will implement a tab system for a restaurant in three different parts:

● Total bill value and value per person

● Tip and Tax

● Itemized bill


Problem 1 – Tab Total

In this first problem, you will write a program that will read how many people are sitting at the table and the value of each purchased item to compute the total cost of the meal.

Your program will first read an integer representing how many people are sitting at the table. Then it will read positive doubles for each item. You will keep reading the doubles until the value is less or equals than zero.

You will then print, to the console, the final value of the bill and how much it costs divided by everyone on the table. Please see the example below.

You must control the output of the percentage to two decimal digits. In Java, you must use the System.out.printf method. In python, you can control the number of decimal digits directly on the print method.

There is a video on using the printf in the "Helpful Resources" folder in Brightspace. Here is the official documentation: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html

Input for Java AND Python: Inputs are separated by Enter, one number per line.


Input

● One int representing the number of people sitting at the table

● N doubles representing the cost of each food item.


Output

The total value of the bill plus the value divided by each person at the table.


Example:

  Input
  Output
  2
  20
  10
  30
  0
  Total: 60.00 CAD
  Divided by 2: 30.00 CAD


Problem 2 – Tip and Tax

Now, you will add a custom tip to the waiter plus the sales tax on the province. The tip should be computed on the value before tax. You should apply the sales tax on the total value of the bill, including the tip.

The user will input the tip value as a percentage from 0 to 100. You must compute the sales tax using the province that the user will input (a two letter uppercase String) using the list below:

● AB, NT, NU, YT – 5%

● SK – 11%

● BC, MB – 12%

● ON – 13%

● QC – 14.98%

● NS, NL, PEI, NB – 15%

The input is similar to Problem 1. The user will first input the number of people at the table, then the cost of each item, one on each line until 0 or a negative value is entered. After, the user will input the tip percentage (0-100) and the province code on the same line.

Your program will print the total before tax, tip amount, total after tax and the total divided by each person. Please see the example below.


Example:

  Input
  Output
  2
  20
  10
  30
  0
  13 ON
  Total before tax: 60.00 CAD
  Tip: 7.80 CAD
  Total after tax: 76.61 CAD
  Divided by 2: 38.31 CAD


Problem 3 – Itemized Bill

In this last problem, you will add an itemized bill; that is, you will print the name and price of each item that was purchased before the bill's total.

You will have to use 1D or 2D arrays and at least one method on this problem. You can create more methods if you want. If you don't create the method described below, you will lose marks on this problem after you submit your assigment.

The input on this problem is different from P1 and P2. In this problem, you will read the number of people at the table then the number of items purchased N. After, you will read N entries of the dish name (string) and price from the console (double). Each is separated by a new line. After, you will read the tip and province like P2.

After you read all the information, you will print first the items then the bill totals (like in P2). To print the itemized list, you must implement a method called printItemizedBill. This method will receive either two 1D arrays or one 2D array (or a list in python). With that information, it will print the list to the console according to the example below.

Tip: If you are writing this assignment in Java, the nextDouble (and nextInt) will leave a \n on the keyboard buffer. You need to clear it before you can read a String with a nextLine. To clear it, just call an extra nextLine.


Example:

  Input
  Output
  2
  5
  salumi misti
  18
  linguine alla carbonara
  17
  tortellini al prosciutto
  20
  crème brûlée al caffè
  10
  coppa al caramello
  10
  20 NS
  Itemized bill:
   - salumi misti : 18.00
   - linguine alla carbonara : 17.00
   - tortellini al prosciutto : 20.00
   - crème brûlée al caffè : 10.00
   - coppa al caramello : 10.00
  Total before tax: 75.00 CAD
  Tip: 15.00 CAD
  Total after tax: 103.50 CAD
  Divided by 2: 51.75 CAD