Question

In: Computer Science

For each of the following problems provide: a. inputs b. outputs c. error conditions d. an...

For each of the following problems provide: a. inputs b. outputs c. error conditions d. an algorithm using the pseudocode reference used in class e. a set of test cases. Be careful about corner cases f. the minimum number of operations executed in your algorithm g. the maximum number of operations executed in your algorithm

Q. Train Ticket for one person. Read a person’s age, then compute and display the price the person needs to pay for the train ride according to the following rules: Children younger than 7 years old ride for free. If the ticket is bought at the train station: A person over 65 years old pays $7.50. Everyone else pays $13.20. If ticket is bought inside the train, there is an extra charge of 20% compared to train station prices. Note that a persons’ age is within the range of 0 to 120 years. Other inputs are error conditions.

Solutions

Expert Solution

Please find the response below:

a,b) Set of inputs and outputs

Age (Input)

Ticket Bought

Fare ($) (Output)

3

0

10

At train station

13.20

50

At train station

13.20

70

At train station

7.5

10

Inside train

15.84

50

Inside train

15.84

70

Inside train

9

c) Error Conditions:

Age : -1

Age : 121

Age: 200

d) Pseudo Algorithm

Input age

If age < 7
   Fare = 0

Else
   If age < 65
       If Ticket Bought At Station
           Fare = 13.20
        Else
           Fare = 15.84

   Else
        If Ticket Bought At Station
            Fare = 7.5
       Else
            Fare = 9

Return Fare

e) Test Cases

Age

Ticket Bought

Fare($)

6

0

7

At train station

13.20

10

At train station

13.20

50

At train station

13.20

65

At train station

13.20

66

At train station

7.5

70

At train station

7.5

10

Inside train

15.84

50

Inside train

15.84

65

Inside train

15.84

70

Inside train

9

f) Minimum number of operations in the algorithm

When age <7 = 4, number of operations = 4

g) Maximum number of operations in the algorithm

When age = 70, number of operations = 6


Related Solutions

Identify inputs, outputs and value addition tasks for the following services: a) Banking b) Courier c)...
Identify inputs, outputs and value addition tasks for the following services: a) Banking b) Courier c) Insurance d) Retail Outlets e) Airlines
For each of the following simplicial complexes ,X = {[a], [b], [c], [d], [a, b], [c,...
For each of the following simplicial complexes ,X = {[a], [b], [c], [d], [a, b], [c, d]}, and X = {[a], [b], [c], [d], [e], [a, b], [b, c], [c, d], [a, d], [a, c], [a, e], [b, e], [a, b, c]},give a basis for each non-zero Hj(X).
Consider the following inputs and outputs associated with a DCS system.
  Consider the following inputs and outputs associated with a DCS system. It is interesting to note that EXACTLY the same could be applicable to a SCADA system (although the SCADA system could use either a dedicated RTU or else a PLC). Break the following signals up (either going to, or away from the RTU-type devices) and indicate which are: i) digital inputs, ii) digital outputs, iii) analog inputs and iv) analog outputs: 18.1 ( 1 mark) START signal 18.2...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called stringToListOfWords() which takes in a String converts it into a list of words. We assumes that each word in the input string is separated by whitespace.3 2Use the equals() method. 3The split() method of String can split an input up along a provided special string called a regular expression or regex. A regex is much like a code...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called removeAllInstances() which takes in a List and item4 . The method then proceeds to remove each item in the list that matches the given item. For example, if the method is passed the List [1, 4, 5, 6, 5, 5, 2] and the Integer 5, the method removes all 5’s from the List. The List then becomes [1,...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called isPermutaion() which takes in two List objects which contain the same types. It returns true if the Lists are permutations of each other and false if not. Two lists are permutations if they contain the same elements, including the same number of duplicates, but they don’t have to contain the elements in the same order. For example, [1,2,...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method named allMultiples() which takes in a List of integers and an int. The method returns a new List of integers which contains all of the numbers from the input list which are multiples of the given int. For example, if the List is [1, 25, 2, 5, 30, 19, 57, 2, 25] and 5 was provided, the new list...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called unique() which takes in a List and returns true if all the items in the List are unique. All the items are unique if none of them are the same.Return false otherwise. Please do this in Java.
Code in C Write a program whose inputs are three integers, and whose outputs are the...
Code in C Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values. int...
Which of the following are measures of capacity in terms of outputs and inputs produced for...
Which of the following are measures of capacity in terms of outputs and inputs produced for the corresponding production system? Select one: A. Airline – customers checked out per hour – reservation calls handled per day B. Supermarket – available seat miles per year – cartons unloaded per hour C. University – graduates per year – students admitted per year D. Automobile assembly plant – autos assembled per year –packages delivered per day In planning the long-term capacity of an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT