Calculator should be able to handle the five basic mathematics operations – +,-,*and divide and modulus – on two input values. Program should have the following structure: Ask the user to enter two float variables named var1 and var2. Ask the user to enter a character variable named operation to represent the operation to be performed on the two variables. Perform the appropriate operation by using if-statements. The output must be given in fixed-point notation with two digits after the decimal point. A typical run is displayed below: Please enter the first float value: 35.6 Please enter the second value: 24.12 Please enter the operation required : The sum of 35.6 and 24.12 is 59.72 Submit both your program and output.
Taru exam is on the head. So she started learning physics. There she learned about Pascal's law. Now she wanted to try an experiment to get a better understanding of the same.
For, the experiment Taru has N buckets (numbered from 1,2,3...N) which all are initially empty.
She has M number of queries. Each query represents an integer that is of 4 types.
•
searchBook( )
–
for a searching book by name or author. It asks the user to enter the
type of search he/she wants i.e. by Book name or by author name.
Design a C++ program that takes character input from user and checks whether that letter is vowel alphabet or not using if...else statement
1. Write a simple decryption program using string functions which will apply the Substitution Method. Here is the given Substitution Table.
1. Write a program using string functions that determine if the input word is a palindrome. A palindrome word is a word that produces the same word when it is reversed.
Write a program using standard string functions that
accepts a price of an item and display its coded value. The
base of the key is:
X C O M P U T E R S
0 1 2 3 4 5 6 7 8 9
Write a program to read the content of a file and copy its content to another file after converting all the capital case letters in the file to small case letters.
The following code is supposed to display the positive even numbers less than 12. That is, it will
output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output
of the code below will be. Then write a small program including the code below and make the necessary
changes to fix the code so that it displays what it is intended to display. Ensure that your program works
correctly. Only submit the program, not the output.
Hint: Use variable diagrams to trace the program to help you find the logical error.
int x = 1;
while (x
!= 12)
{
cout << x <<
endl; x = x +
2;
}
A bookshop gives discount to customers as follows:
• Students get 10% discount,
• Book dealers get 12% discount and
• Pensioners get 15% discount.
• All other customers get 10% discount only if their total purchases are more than R200.
You are requested to write two versions of a program that calculates and displays the final amount that is
due, after discount.
(i) The first version of the program uses a switch statement to implement the above program.
(ii) The second version of the program uses nested-if statements.
Hint:
Use the following variables:
float amount; // the amount due before discount
char customerType; // the type of customer: 'S' (student) or
// 'D' (dealer) or 'P' (pensioner) or
COS1511/103/0/2022
5
// 'O'(other) float discount,