In the code editor, you are provided with a main() function that asks for an integer input from the user which represents the cash to be given to Lionel and passes it to the getGift() function call.
The getGift() function is already declared and partially defined. Your task is to complete the function definition.
The getGift() function multiplies the passed integer value by 3 and then checks if the result is even. If it is, the getGift() function adds 100 to the result. Otherwise, it adds 200 to the result.
The getGift() function would then return the result as the return type of this function is int.
Given code:
#include <iostream>
using namespace std;
int getGift(int);
int main(void) {
int cash;
cout << "Enter cash amount: ";
cin >> cash;
int result = getGift(cash);
cout << "I'm giving you P" << result;
return 0;
}
int getGift(int cash) {
// TODO: Implement the function definition
}
Your task is to define the sendApology() function with the following details:
a. Return type - void
b. Function name - sendApology
c. Parameters - a character and an integer.
The sendApology() function will first check if the character passed is either 's', 'o', 'r', or 'y'. If it is, print it based on the passed integer number of times. For example, if the passed integer is 5, then you need to print the character 5 times. Otherwise, just ignore it (i.e. don't do anything).
Do not edit the main() code.
This is the given code:
#include <iostream>
using namespace std;
int main(void) {
sendApology('s', 2);
sendApology('f', 10);
sendApology('b', 3);
sendApology('o', 5);
sendApology('r', 12);
sendApology('m', 5);
sendApology('v', 2);
sendApology('y', 7);
return 0;
}
void sendApology(char letter, int n) {
// TODO: Implement the function definition
}
Vowels Survival
by CodeChum Admin
Make me a program that accepts two random strings. Then, count the number of vowels that are in each of the strings and put it on separate variables.
Finally, for the survival of the vowels, subtract the total count of vowels of the first string to the vowels of the second string then print out its difference.
Easy, right? Then go and code as if your life depends on it!
Input
Two lines containing a string on each.
C++·is·fuN CodeChum·is·AWEsome
Output
A line containing an integer.
6
Search and Rescue
by CodeChum Admin
Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.
Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".
Start coding now!
Input
The first line contains the size of the array. The next lines contain the integers. The last line contains an integer to be searched.
5 3 21 2 5 23 2
Output
A line containing a string.
Present
Your task is to implement the class Loan with the following requirements:
• A member variable that will hold the annual interest rate of the loan. Its default value will be 2.5.
• A member variable that will hold the number of years for the loan. Its default value will be 1.
• A member variable that will hold the loan amount. Its default variable will be 1000.
• A default constructor.
• Another constructor that has interest rate, years, and loan amount as its parameters.
• A member function that returns the annual interest rate of this loan.
• A member function that returns the number of the years of this loan.
• A member function that returns the amount of this loan.
• A member function that sets a new annual interest rate to this loan.
• A member function that sets a new number of years to this loan.
• A member function that sets a new amount to this loan.
• A member function that returns the monthly payment of this loan.
• A member function that returns the total payment of this loan.
(Hardware Inventory) You are the owner of the hardware store and need to keep an inventory that can tell you what different tools you have, how many of each you have on hand and the cost of each one. Write a program that lets you input the data concerning each tool, enables you to list all your tools, lets you delete a record for a tool that you no longer have and lets you update any information in the file. The tool identification number should be the record number. Use the following information to start your file.
RECORD#
TOOL NAME
QUANTITY
COST
3
Electric Sander
7
57.98
17
Hammer
76
11.99
24
Jig Saw
21
11.00
39
Lawn Mower
3
79.50
56
Power Saw
18
99.99
68
Screwdriver
106
6.99
77
Sledge Hammer
11
21.50
83
Wrench
34
7.50
Problem # 2
SM Supermalls is one of Southeast Asia's biggest developers and the operator of 72 malls in the Philippines. Create a C++ program that displays the number of rewards points an SM Mall customer earns each month. The rewards points should be based on membership type and total purchased amount each month. The output should be in a fixed point notation with no decimal places.
Membership Type
Advantage
Total Monthly Purchase
Less than 3750
3750 7499
7500 and over
Prestige
Less than 10,000
10,000 and over
Reward points
5% of the total monthly purchased
7.5% of the total monthly
10% of the total monthly
4% of the total monthly
15% of the total monthly
I need a code that will print all possible combinations and permutations of an array of words (eg. "alpha", "beta", "delta").
The code should be such that it permutates each line from the result of the combination, where 'r' will be the number of elements that will be selected at a time from the array.
A function that returns an int can only use int parameters.
True
False
When a function ends, the local variable and parameter variables are destroyed.
True
False