C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

(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:

 

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 

Possible values of i is any positive value from 2 to 10

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




Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah".


Let's try this out now!


Input


1. 3-digit number

2. Digit to be checked

Output


The first line will contain a message prompt to input the 3-digit integer.

The second line will contain a message prompt to input the digit to be checked.

The last line contains the appropriate string.


Company ABC in Kenya pays its employees based on a commission of the sales they make as

illustrated in the table below:

Monthly Sales Commission Rate

First 50,000 10%

Next 100,000 15%

Next 200,000 20%

Above 350,000 25%

Additionally, all employees are entitled to a basic commission of 20,000 per month.

a. Draw a flowchart that allows a HR employee to input an employee’s monthly sales,

computes the commission due to the employee and displays it to the HR employee.

[7 Marks]

b. Write a C++ program implementation of the flowchart above. [8 Marks]


LATEST TUTORIALS
APPROVED BY CLIENTS