QUESTION 2 4 MARKS In Questions 2.1 and 2.2 you have to write down what the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
QUESTION 2 4 MARKS In Questions 2.1 and 2.2 you have to write down what the purpose of the segment of code is. Look at the following example before answering the questions: 2.1 int a,b,c cin >> >> >> cout < < c + b + a: The purpose of the above code segment is to input three integer values and display their sum Now answer questions 2.1 and 2.2 below: Assume that and have been declared as integers. Explain in words what the purpose of the following segment of code is: (2) int 0 int n = 0; while in <5) ( QUESTION 3 1 an 2.2 Explain the purpose of the following segment of code: n++; int numbers 1 (11, 0, 15, 0, 16, 231; inte - 0: for (int i= 0; i Chrome. QUESTION 4 INP1501 Oct-Nov 20... Number of registrants 1 through 4 5 through 10 11 or more 07:59 Complete the program below. 8 MARKS Karlton Learning wants a program that displays the amount of money a company owes for a seminar. The fee per person is based on the number of people the company registers. For example, if the company registers 7 people then the amount owed is R 560.00. If the user enters a number that is less than or equal to 0, the program should display an appropriate error message. #include using namespace std; int main() ( Fee per person R100.00 R 80.00 R 60.00 4 89% INP1501 Oct/Nov 2023 // Question 4.1 (2) // Declare a variable to hold the number of registrants and a // variable to hold the amount a company owes for a seminar. // Question 4.2 (2) // Write statements to input the number of registrants. If the //user enters a number that is less than or equal to 0, the // program should display an appropriate error message. int nrWheels: int countTwo, countFour, countMore; // Question 4.3 (4) // Write statements to calculate and display the amount of money // a company owes for a seminar. return 0; QUESTION 5 In order to plan road maintenance, the department of Road Works request that road usage must be determined. This is done by counting the number of vehicles using the road with two wheels, four wheels and more than four wheels respectively. Write down ONLY the necessary switchstatement to count the number of vehicles with two wheels, four wheels and more than four wheels. Do NOT write a complete program. Use the following variables: 5 MARKS // number of wheels of a vehicle using the road // the counters for the // number of vehicles with // two, four and more than //four wheels respectively [TURN OVER] Chrome. 6.1 INP1501 Oct-Nov 20... 4 Assume that countTwo, count Four and count More have been initialised already and that a value has been input and validated for nrWheels. QUESTION 6 6.2 6.3 6.4 1 2 4 Write a for-statement to display the numbers 1 through 10 on the screen. Write a while-statement to display the numbers 1 through 10 on the screen. The code below should display the numbers 1, 2, 3and on the screen. However, the code is not working correctly. Correct the errors in the code. (2) 1 2 4 5 6 7 int num = 1; while (num <4) QUESTION 7 07:59 cout < < num < < endl; // endwhile The code below should display each salesperson's commission. The commission is calculated by multiplying the salesperson's sales by 10%. The code is not working correctly. Correct the errors in the code. (2) float sales - 0.0; float commission = 0.0: cout < < "Enter a sales amount: "; cin >> sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023 8.1 8.2 int average: values have been assigned already to all the elements of the array the function is called in the main function as follows: average calcAverage (crates); Write down ONLY the complete function calcAverage. QUESTION 8 Write a function header for the function checkthat has two parameters. The first parameter should be an integer value and the second parameter a floating point value. The function returns no value. (1) // the average number of crates 8.6 [TURN OVER] INP1501 Oct/Nov 2023 Write a function header for the function mult that has two floating point numbers as parameters and returns the result of multiplying them. 8.3 Write a function header for the function time that inputs seconds, minutes and hours and returns them as parameters to its calling function. (1) 8 MARKS 8.4 Write a function header for the function countlet sthat returns the number of occurrences of a character in a string, both provided as parameters. (1) QUESTION 9 8.5 Suppose the following declarations appear in the mainfunction of a C++ program: int numbers float cost, markup, discount, Also, suppose the following calling statement appears in the mainfunction amount - caleFinal (67.50, markup, discount, 532 Write the correct function header of the function calcFinal? Suppose the following declarations appear in the mainfunction of a C++ program string dayOfWeek; int product Code, number; float discount 11 If the following function header is given void caleDiscount (float & discount, ist product Code?. int number?, string dayofWeek?); give the correct calling statement of the function calebiscount in the mainfunction (2) (2) [TURN OVER] INP1501 Oct/Nov2023 & MARKS Bookworm bookstores announced a competition running over four weeks for their three branches The branch with the highest sales per week will receive a surprise for that week. You as a asted to write a program to lear ecord of the number of books programmat Chrome. 6.1 INP1501 Oct-Nov 20... 4 Assume that countTwo, count Four and count More have been initialised already and that a value has been input and validated for nrWheels. QUESTION 6 6.2 6.3 6.4 1 2 4 Write a for-statement to display the numbers 1 through 10 on the screen. Write a while-statement to display the numbers 1 through 10 on the screen. The code below should display the numbers 1, 2, 3and on the screen. However, the code is not working correctly. Correct the errors in the code. (2) 1 2 4 5 6 7 int num = 1; while (num <4) 07:59 QUESTION 7 cout < < num < < endl; // endwhile The code below should display each salesperson's commission. The commission is calculated by multiplying the salesperson's sales by 10%. The code is not working correctly. Correct the errors in the code. (2) float sales - 0.0; float commission = 0.0: cout < < "Enter a sales amount: "; ein >> sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023 QUESTION 2 4 MARKS In Questions 2.1 and 2.2 you have to write down what the purpose of the segment of code is. Look at the following example before answering the questions: 2.1 int a,b,c cin >> >> >> cout < < c + b + a: The purpose of the above code segment is to input three integer values and display their sum Now answer questions 2.1 and 2.2 below: Assume that and have been declared as integers. Explain in words what the purpose of the following segment of code is: (2) int 0 int n = 0; while in <5) ( QUESTION 3 1 an 2.2 Explain the purpose of the following segment of code: n++; int numbers 1 (11, 0, 15, 0, 16, 231; inte - 0: for (int i= 0; i Chrome. QUESTION 4 INP1501 Oct-Nov 20... Number of registrants 1 through 4 5 through 10 11 or more 07:59 Complete the program below. 8 MARKS Karlton Learning wants a program that displays the amount of money a company owes for a seminar. The fee per person is based on the number of people the company registers. For example, if the company registers 7 people then the amount owed is R 560.00. If the user enters a number that is less than or equal to 0, the program should display an appropriate error message. #include using namespace std; int main() ( Fee per person R100.00 R 80.00 R 60.00 4 89% INP1501 Oct/Nov 2023 // Question 4.1 (2) // Declare a variable to hold the number of registrants and a // variable to hold the amount a company owes for a seminar. // Question 4.2 (2) // Write statements to input the number of registrants. If the //user enters a number that is less than or equal to 0, the // program should display an appropriate error message. int nrWheels: int countTwo, countFour, countMore; // Question 4.3 (4) // Write statements to calculate and display the amount of money // a company owes for a seminar. return 0; QUESTION 5 In order to plan road maintenance, the department of Road Works request that road usage must be determined. This is done by counting the number of vehicles using the road with two wheels, four wheels and more than four wheels respectively. Write down ONLY the necessary switchstatement to count the number of vehicles with two wheels, four wheels and more than four wheels. Do NOT write a complete program. Use the following variables: 5 MARKS // number of wheels of a vehicle using the road // the counters for the // number of vehicles with // two, four and more than //four wheels respectively [TURN OVER] Chrome. 6.1 INP1501 Oct-Nov 20... 4 Assume that countTwo, count Four and count More have been initialised already and that a value has been input and validated for nrWheels. QUESTION 6 6.2 6.3 6.4 1 2 4 Write a for-statement to display the numbers 1 through 10 on the screen. Write a while-statement to display the numbers 1 through 10 on the screen. The code below should display the numbers 1, 2, 3and on the screen. However, the code is not working correctly. Correct the errors in the code. (2) 1 2 4 5 6 7 int num = 1; while (num <4) QUESTION 7 07:59 cout < < num < < endl; // endwhile The code below should display each salesperson's commission. The commission is calculated by multiplying the salesperson's sales by 10%. The code is not working correctly. Correct the errors in the code. (2) float sales - 0.0; float commission = 0.0: cout < < "Enter a sales amount: "; cin >> sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023 8.1 8.2 int average: values have been assigned already to all the elements of the array the function is called in the main function as follows: average calcAverage (crates); Write down ONLY the complete function calcAverage. QUESTION 8 Write a function header for the function checkthat has two parameters. The first parameter should be an integer value and the second parameter a floating point value. The function returns no value. (1) // the average number of crates 8.6 [TURN OVER] INP1501 Oct/Nov 2023 Write a function header for the function mult that has two floating point numbers as parameters and returns the result of multiplying them. 8.3 Write a function header for the function time that inputs seconds, minutes and hours and returns them as parameters to its calling function. (1) 8 MARKS 8.4 Write a function header for the function countlet sthat returns the number of occurrences of a character in a string, both provided as parameters. (1) QUESTION 9 8.5 Suppose the following declarations appear in the mainfunction of a C++ program: int numbers float cost, markup, discount, Also, suppose the following calling statement appears in the mainfunction amount - caleFinal (67.50, markup, discount, 532 Write the correct function header of the function calcFinal? Suppose the following declarations appear in the mainfunction of a C++ program string dayOfWeek; int product Code, number; float discount 11 If the following function header is given void caleDiscount (float & discount, ist product Code?. int number?, string dayofWeek?); give the correct calling statement of the function calebiscount in the mainfunction (2) (2) [TURN OVER] INP1501 Oct/Nov2023 & MARKS Bookworm bookstores announced a competition running over four weeks for their three branches The branch with the highest sales per week will receive a surprise for that week. You as a asted to write a program to lear ecord of the number of books programmat Chrome. 6.1 INP1501 Oct-Nov 20... 4 Assume that countTwo, count Four and count More have been initialised already and that a value has been input and validated for nrWheels. QUESTION 6 6.2 6.3 6.4 1 2 4 Write a for-statement to display the numbers 1 through 10 on the screen. Write a while-statement to display the numbers 1 through 10 on the screen. The code below should display the numbers 1, 2, 3and on the screen. However, the code is not working correctly. Correct the errors in the code. (2) 1 2 4 5 6 7 int num = 1; while (num <4) 07:59 QUESTION 7 cout < < num < < endl; // endwhile The code below should display each salesperson's commission. The commission is calculated by multiplying the salesperson's sales by 10%. The code is not working correctly. Correct the errors in the code. (2) float sales - 0.0; float commission = 0.0: cout < < "Enter a sales amount: "; ein >> sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Pet Energy Therapy Association (PETA) treats peoples' pets, and has the following cost structure: Charge per therapy session$95 Variable cost per therapy session$ 45 Fixed costs$75,000 They expect to...
-
You had bought prize bonds and you won one of them. Now you are given three options to collect your reward. You can elect to receive a lump sum today of PKR 50 million, or to take 20 end of year...
-
Problem 2 Emma Li successfully finished her MBA and now works as the CFO of the Great Lake Industries, a manufacturer of snowmobiles, all-terrain vehicles (ATVs), and neighborhood electric vehicles....
-
Determine the x-and y-intercepts on the graph of the equation. Graph the equation. y=-1.5x + 15
-
Three sheets of plastic have unknown indices of refraction. Sheet 1 is placed on top of sheet 2, and a laser beam is directed onto the sheets from above so that it strikes the interface at an angle...
-
Valdez Plastics Company uses a job order cost system to account for its production costs. During the current period, 1,000 chairs were molded and assembled as Job 9823. The total cost incurred on the...
-
Draw a relative frequency histogram for the frequency distribution in Example 2. Data from Example 2 Using the frequency distribution constructed in Example 1, find the midpoint, relative frequency,...
-
The Eaststate Manufacturing Company produces four different airplane parts from fabricated sheet metal for several major aircraft companies. The manufacturing process consists of four...
-
What is the effect on the three statements when a company issues 1 0 0 shares for $ 5 0 each?
-
Change Janets Schedule In Question 5 Above, You Calculated What The Schedule Would Look Like If Janet Had Made One $285.05 Payment In January 2022. You Did It By Hand, But The Bankrate Calculator Has...
-
An iPhone 13 costs $600 in the United States. Today, forex exchange rates were identified at: $1 = 2.25 1 = P43 What should be the price of the same iPhone 13 in Philippines, assuming that the...
-
If an HR professional was making an organizational decision by determining the gain or loss that resulted from that decision, which measurement concept would he be using?
-
Solving Worldly Issues with Entrepreneurship For this project, you will apply your entrepreneurial and enterprising skills to a global issue or problem. Use the following steps to structure your...
-
Who develops Kali Linux? What distribution was the predecessor to Kali Linux? 2. What is the main purpose(s) of the Kali Linux distribution? 3. What are the installation options for Kali Linux?...
-
Suppose back in 2000, the average ticket price of the Houston Symphony was $66.9 years later, the average ticket price increased to $81. What was the growth rate of the average ticket price over the...
-
Have you heard of "The Five Forces model" popularized by Harvard professor Michael Porter, that is a framework for analyzing the attractiveness of an industry? These readings came from the book...
-
A block is resting on an incline of slope 5:12 as shown in Fig. P-007. It is subjected to a force F = 500 N on a slope of 3:4. Determine the components of F parallel and perpendicular to the incline....
-
Reduction in sales All of the above 29. Belt of an electric motor is broken, it needs a. Corrective maintenance b. Scheduled maintenance c. Preventive maintenance d. Timely maintenance. 30. The...
-
Clarita is a single taxpayer with two dependent children, ages 10 and 12. Clarita pays $3,000 in qualified child care expenses during the year. If her adjusted gross income (all from wages) for the...
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
Matthew borrows $250,000 to invest in bonds. During 2012, his interest on the loan is $30,000. Matthew's interest income from the bonds is $10,000. This is Matthew's only investment income. a....
-
Is it always possible to discern a trend in any time-series data? What problems might arise if trends are apportioned to time-series data that are not really present?
-
Why might household and firms confidence and expectations change leading to deviations in output from trend? Is there any way in which changes in confidence can be measured to provide an indicator of...
-
Firms experience a rise in stocks. Explain why this might have occurred and what you expect firms response to this event might be and how this might affect output.
Study smarter with the SolutionInn App