Consider the problem of making change for N cents using the fewest number of coins. Assume that the coin set consists of c1, c2, …, cd; and each coin’s value is an integer. Write a greedy algorithm for that.
Sample input:
4
1 10 25 5
173
Sample output:
#25 cents --- 6
#10 cents --- 2
#1 cents --- 3
Total 11 coins
sample input:
2
3 5 16
sample output:
#5 cents --- 3
Opps! can’t form 16 taka
Implement the Shape hierarchy designed (which is based on the hierarchy of Fig below). Each TwoDimensionalShape should contain function getArea to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have member functions getArea and getVolume to calculate the surface area and volume, respectively, of the three-dimensional shape. Create a program that uses a vector (array) of Shape pointers to objects of each concrete class in the hierarchy. The program should print the object to which each vector (array) element points. Also, in the loop that processes all the shapes in the vector (array), determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its area. If a shape is a ThreeDimensionalShape, display its area and volume
Implement the Shape hierarchy designed (which is based on the hierarchy of Fig below). Each TwoDimensionalShape should contain function getArea to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have member functions getArea and getVolume to calculate the surface area and volume, respectively, of the three-dimensional shape. Create a program that uses a vector (array) of Shape pointers to objects of each concrete class in the hierarchy. The program should print the object to which each vector (array) element points. Also, in the loop that processes all the shapes in the vector (array), determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its area. If a shape is a ThreeDimensionalShape, display its area and volume
1. Using the looping statement. Create a program that will display the following:
A. 5
10
15
20
25
30
B. 100 90 80 70 60 50 40 30 20 10
Write a C++ program that will: 5.1 Accept student’s information into three parallel arrays. The capture of the students’ marks must be a sentinel-controlled mark that is below zero for either the continuous assessment (term) mark or the final mark. Use a sentinel-controlled loop that will exit when the user types in the word ’Done’ instead of a student’s name. For each mark, use a function: int validateData(string,int) that receives a message to be displayed to the user in case the mark is not acceptable, and also the captured mark. Marks can only be between 0 and 100.
1. Read 10 integers from the keyboard in the range 0 - 100, and count how many of them are larger than 50, and display this result.
1. Using the looping statement. Create a program that will display the following:
A. 5
10
15
20
25
30
B. 100 90 80 70 60 50 40 30 20 10
You are required to create a programming to display the pricing, discounted value, who is the seller and postage company.
Please include the necessary library before typing your codes.
Item: shoe, smartphone, Tv, Table fan
Brand: adidas, apple, Samsung, Media
Model: Super-star, 12, S50LED, M17T
Price (RM): 450.99, 4569.99, 1999.99, 555.55
Discount (%): 25.75, 10.75, 20.25, 15.25
Seller: DEF Sdn Bhd, Enjit2 Semut Enterprise, Ah Huat sdn bhd, Jalin enterprise
Postage: Lazada pos, GRAB, City Link, Postlaju.
The output from the codes must have the command COUT for every item.
Construct the necessary script to solve the given problem.
1. Using the looping statement. Create a program that will display the following:
A. 5
10
15
20
25
30
B. 100 90 80 70 60 50 40 30 20 10
Q1. Define a class Deposit that has a principal, a rate of interest, which is fixed for all
deposits and a period in terms of years. Write member functions to
(i) alter(float) which can change the rate of interest.
(ii) interest() which computes the interest and returns it.
(iii) print() which prints data as shown below. Note that the width of each column is 20.
5mks
Q2. Assume that the cell users are two kinds – those with a postpaid option and those
with a prepaid option. Postpaid gives a fixed free talk time and the rest is computed at
the rate of N2.90 per pulse. Prepaid cards have a fixed talk time.
Define a class Cell_user as a base class and derive the hierarchy of classes. Define
member functions and override them wherever necessary to
(i) retrieve the talk time left for each user.
(ii) print the bill in a proper format containing all the information for the postpaid user.