[Solved] COMP248 Assignment 3-Producing a flowchart given code

$25

File Name: COMP248_Assignment_3-Producing_a_flowchart_given_code.zip
File Size: 499.26 KB

SKU: [Solved] COMP248 Assignment 3-Producing a flowchart given code Category: Tag:
5/5 - (1 vote)

Welcome to The Program

Please enter the number of sequences

5

The result is:

,,,,

Do you want to repeat? (Yes/No)

Yes

Please enter the number of sequences

3

The result is:

,,

Do you want to repeat? (Yes/No)

No

Thank you for choosing our program, have a nice day!

Figure 2- Sample output for question 1

Question 2 Cashier Calculator

For this question you are required to write a Cashier Calculator, which will compute the total price of some items including taxes (Tax1 & Tax2).

The subtotal, taxes, and total price are calculated as follows:

SubTotal = where n = number of items bought and P(i) = the price of item i.

Tax1 = SubTotal tax1Rate

(e.g., tax1Rate =0.06 stands for 6%)

Tax2 = (SubTotal + Tax1) tax2Rate

(e.g., tax2Rate=0.075 stands for 7.5%)

Total = SubTotal + Tax1 + Tax2

Your program will require the user to enter the following:

  • The number of items
  • The price of each item
  • The Tax1 rate in percentage
  • The Tax2 rate in percentage

The following constraints are given:

x The minimum number of items is 1 and the maximum number of items is 10.

x The minimum price of each item is $1 and the maximum price of each item is $1,000. The price may be a decimal number.

x The minimum tax rate for Tax1 and Tax2 is 0 and the maximum tax rate is 100. Suppose the tax rate is 12.345%, the user will enter 12.345. You will need to divide it by 100 to compute the tax rates. You can assume that the user will not enter the % symbol.

x All of the above minimum and maximum values are constants, i.e., they remain unchanged throughout the entire program. You should know how to define them.

The program must behave in the following manner:

x The program will require the user to enter the needed values one after another. If any of the entered values is invalid, then the program will detect that and go into a loop requiring the user to enter a valid value. The program must keep track of the total number of invalid values that the user has entered.

x Using SubTotal and tax1Rate, the program should compute Tax1. x Using Tax1 and tax2Rate, the program should compute Tax2.

x The program will calculate the SubTotal, Tax1, Tax2 and Total then display the following:

  • How many times the user has entered invalid values for all the required inputs.

If the user did not enter any invalid value, then no message should be displayed. In other words, You have entered 0 invalid inputs should NOT be displayed if the user has entered all values correctly.

  • The subtotal o The Tax1 o The Tax2 o The total

x The displayed subtotal, Tax1, Tax2, and total must have 2 decimal places.

Here is a sample output to illustrate the expected behavior of your program. User input is in green.

-$-$-$-$-$-$-Welcome to Cashier Calculator Program-$-$-$-$-$-$-Please enter the number of items bought [110]: 0 Please enter the number of items bought [110]: 2 Please enter the price of items 1 [11000]: 0Please enter the price of items 1 [11000]: 100.50Please enter the price of items 2 [11000]: 500Please enter the tax rate of Tax1 [0100]: 11111Please enter the tax rate of Tax1 [0100]: 5Please enter the tax rate of Tax2 [0100]: 7.5 Here are your resultsYou have entered 3 invalid inputs.Subtotal: $ 600.50Tax 1: $ 30.03Tax 2: $ 47.29 TOTAL: $ 677.81 Hope you shopping trip was an enjoyable one!

Figure 3- Sample output for question 2

Question 3 Producing a flowchart given code

Given the code below:

  1. What is the output of the program?
  2. Draw an appropriate flowchart for this program.
import java.util.Scanner; class A3Q3{public static void main (String[] args){ //Variable declarationScanner scanner = new Scanner(System.in);int i = 0 ,value = 0, n;String string = ; System.out.println(Enter the value of n:);n = scanner.nextInt(); for (i = 1; i <= n; i++){int counter=0;for(value = 1; value <= i; value++){if(i%value==0){counter = counter + 1;}}if (counter == 2){string = string + i + ;}} System.out.println(Output is :);System.out.println(string); scanner.close();}}

How to submit the answers to this question?

Option 1: Draw your flowchart by hand and write up your answers to questions a) and b); and submit a photo of your answers which you zip together with your .java files for questions 1 and 2.

Option 2: Use one of the free s/w for flowchart drawing, or Word or even Power Point. Dont forget to include the answers to questions a) and b) of this questions.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP248 Assignment 3-Producing a flowchart given code
$25