WAP to find sum of number 1 to 10 using constructor , where n is parameter passed to constructor.
When will the ‘break’ and ‘continue’ statements be used in programme? Mention the scenario
and write the programme to demonstrate this.
Input numbers from the user and find the sum of all those input numbers until the user
inputs zero. In other means, the loop should end when the user enters 0. Finally, display the
sum of all those numbers entered by the user.
You work in a printing office that the machine there can print documents in different colors. It gets an integer number between 1 to 7 and prints the documents in rainbow colors, as shown in the following table:
Number Matched Color
1 Violet
2 Indigo
3 Blue
4 Green
5 Yellow
6 Orange
7 Red
Design an algorithm and write a C++ program to do the following:
Sample Run
Enter a number between 1 and 7: 2
You have selected number 2 which is orange.
Output File "color.txt"
You have selected number 2 which is orange.
Here are the numbers and match colors:
1 ------- Violet
2 ------- Indigo
3 ------- Blue
4 ------- Green
5 ------- Yellow
6 ------- Orange
7 ------- Red
Write a Program: Invoice
A customer makes a purchase at the store. The tax rate is 8% on all purchases
except groceries. The store offers a 5% discount to seniors 60 and over. You
should ask the user three questions: what they have bought (use a menu
displaying bread, milk, or soap), what the purchase price is, and how old they are.
Your goal is to print a formatted invoice with the following line items: price, tax,
discount, and total. The discount should only be printed if applicable.
You should test your program with 5 data sets: with and without tax and with and
without the senior discount. The fifth data set makes an invalid choice of the
menu item, in which case your program should not ask any more questions and
output an error message.
You are hired by an ice-skating center. Your job is to write a program to do calculate the admission fees as follows:
• Children 6 and younger $8.50
• Children 7 and older. $10.50
• Adults $12.00
• Seniors $9.50
There will be 10% tax. PNG students, staff, and faculty will receive 25% discount (before tax).
Design an algorithm and write a C++ program that prompts the user to input the number of tickets in each group age and if the user is a student, staff, or faculty at PNG. The program calculates and outputs the admission fees as illustrated in the sample runs.
Output:
Are you PNG student, staff, or faculty?
Enter Y for yes or enter N for no: Y
Enter the number of children 6 and younger : 1
Enter the number of children 7 and older : 1
Enter the number of adults : 1
Enter the number of seniors : 1
******You received %25 Discount*****
Subtotal ......$30.38
Tax ...........$3.04
Total .........$33.41
Write a complete program from the #include at the top through return 0; } at the bottom.
Define three char variables char1, char2, and char3
(You may also wish to define a result variable).
Have the user enter three lowercase char characters.
(You may assume that the user correctly enters three lowercase characters.)
Compare these three characters and print only the character
that appears first in the alphabet
Take input of your registration number in the University using appropriate data type. Write a
programme to print all the prime number digits, each in a new line, in your registration
number
Input numbers from the user and find the product of all those input numbers until the user
inputs a negative number. In other means, the loop should end when the user enters a
negative number. Finally, display the product of all those positive numbers entered by the
user
C++ program) that will accept an integer value in the range of 5-95 inclusive. Your solution should also ensure that input values ar in multiples of 5. Based on valid input, your solution should calculate how many coins of each denomination should be returned, and display this to the user. Coin values are 50, 20, 10 and 5. The solution should aim to give as much of the higher valued coins as possible. For example, a poor solution for an input of 30 cents would give six 5 cent coins. A correct solution would give a 20 cent coin and a 10 cent coin. After each output, the user should be asked whether they wish to continue or exit/terminate the program. Your solution (algorithm and program) should be designed using a modular approach. This requires the submission of a structure chart, a high level algorithm, and subsequent decompositions of each step (i.e. low-level algorithms). Hint 1- multple of 5 condition. 2- do while loop in switch to terminate the question. 3- no of inp is divisible of 5