Write a program to try-catch blocks can be nested. Also ,an exception can be re-thrown using thrown
(iii) Write a C++ program where the user will enter temperature in Fahrenheit to convert it into
Centigrade, then display the result on the screen:
Roll an N sided die until the sum of the numbers drawn is not exactly equal to X (N and X chosen by the user): if the sum exceeds X, the next drawn number must be subtracted from the sum itself
Given the Table 1 below that shows the Malaysia Ringgit currency exchange rate at Bank A. Draw the flowchart to design the logical flow for currency rate calculator. User needs to key-in the amount of Ringgit Malaysia he/she has and choose currency code target. Your currency rate calculator needs to calculate the amount obtained after the conversion according to the rate shows in Table 1 and display it to the user.
Calculation Example:
Amount: 8 Malaysian Ringgit
Currency code Target: 131
Amount obtained: 8*0.51 = 4.08 Australian Dollar
Table 1
Currency code
Currency Name
Rate
110
Canadian Dollar
4.09
120
France Franc
2.09
125
Germany Mark
1.86
131
Australian Dollar
0.51
LOOPING STATEMENTS AND FUNCTIONS
Create a flowchart to guide you in the process
Create a function that will accept the value of i and return the value of n
Possible values of i is any positive value from 2 to 10
n is computed based on the value of i; see the following table for the sample Input / Output
i Process n
3 1*2*3 6
5 1*2*3*4*5 120
7 1*2*3*4*5*6*7 5040
Screen/Layout
(Home Screen)
Input i:3
Process: 1*2*3
Output: 6
Try Another [Y/N]: Y
Input i: 5
Process: 1*2*3*4*5
Output: 120
Try Another [Y/N]: Y
You are an employee of a marketing organization that pays you a monthly salary of Ksh. 10,000
if you work for the recommended 160 hours a month (Monday - Friday, 9am - 5pm, for a month).
This salary can however fluctuate based on the number of hours worked, in that if you work for
more than the recommended working hours ie above 160 hours, you earn an extra 10% of your
salary but if you work for less than 160 hours, you will be deducted 10% of your salary. With the
aid of a SWITCH CASE select structure Implement a program written in C++ that would help
the finance department calculate your monthly salary based on the hours worked being the input
value of the program. [5 Marks]
a. Given the following array of 8 integers {2,3,2,1,2,5,8,2} you are required to write a
C++ program that will loop through it and re-arrange it into the following final output
{5,3,1,8,2,2,2,2} and display it . The idea is to position all values equal to 2 in the
array to come after the other values not equal to 2. The order of the other values i.e 5,1,3
and 8 does not matter as long as they appear positioned before all 2s as illustrated in the hint
below:
Initial array: {2,3,2,1,2,5,8,2}
NumbertoMove = 2
Final Array: {5,3,1,8,2,2,2,2}
Write an algorithm as a pseudocode to solve the problem above. [7 Marks]
b. Transform the pseudocode in part (a) above into an actual C++ program that filters all
values equal to 2 in the array to come after the other values not equal to 2. The order of the
other values i.e 5,1,3 and 8 does not matter as long as they appear positioned before all 2s.
10-in-1
by CodeChum Admin
Troy who is in his 1st grade and is having a hard time learning how to count numbers from 0 – 50. He asked his brother Gabriel to teach him how to count, but he requested to do teach it 10 numbers per line. His brother don't know how to teach his brother so he looking for a friend who can help him. Can you help Gabriel to do a program that can teach Troy to count numbers by printing it 10 numbers per line? If the numbers exceed or is equal to 50, the output should display "Number must be below 50!".
Input
1. Size of Numbers
Description
The size of the numbers.
Constraints
The value is guaranteed to be a positive integer.
Sample
17
Output
The first line will contain a message prompt to input the size.
The succeeding lines will contain the numbers or the message required if the number is greater than 50.
Enter·size:·17
0·1·2·3·4·5·6·7·8·9
10·11·12·13·14·15·16
Make a program that will accept an integer and loop from 1 to that integer. Then, print all numbers from that range that are greater than 3.
Enter the Customer Name: Abcd
Enter the Type of Meal: 1
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 2
Total Amount of Abcd order is: 140.00
Would you like to try again? (Y/N)?: y
********* Ordering System ***********
Enter the Customer Name: Def
Enter the Type of Meal: 2
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 1
Total Amount of Abcd order is: 100.00
Would you like to try again? (Y/N)?: y
********* Ordering System ***********
Enter the Customer Name: Xyc
Enter the Type of Meal: 2
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 1
Total Amount of Abcd order is: 100.00
Would you like to try again? (Y/N)?: n