100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COS1511 Introduction To Programming 1Assignment 1 2022 (Questions).

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
12-07-2022
Written in
2021/2022

COS1511 Introduction To Programming 1Assignment 1 2022 (Questions). Question 1 Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the keyboard. For example, if the recipe needs 2 cups of flour the output displayed will be something like this Please enter the factor to multiply the ingredients with : 4 Recipe name Ingredients // other ingredients 8 cups flour Method The program has the following structure: • Declare an int variable named mFactor to store the value with which the quantity of each ingredient must be multiplied. • The program must make use of a cin statement to input a value from the keyboard and store it in mFactor. Submit both your program and output. COS1511/103/0/2022 3 Question A teacher at Leva Primary School needs to divide her class in different group sizes according to the activity they have to do. This will help her to prepare workstations for each group. For example, for art projects the class has to be divided in groups of 6; for science projects the class has to be divided in groups of 4. She asked you to write a program to determine the number of groups as well as the number of pupils who are left to form a smaller group. There are 56 pupils in the class. The program has the following structure: • Declare three int variables nrPupils, nrGroups, and nrLeft. nrPupils represents the number of pupils in a class, nrGroups represents the number of groups the class is divided into, and nrLeft represents the number of pupils, if any, who are in the remaining smaller group. • Assign the value 56 to nrPupils. • Declare an int variable groupSize that is used by a cin statement to input a value from the keyboard and store the size of the groups the teacher requested. Display an appropriate message. E.g. Please enter the size of each group? • Write the statement to calculate the number of groups of size groupSize. • Write the statement to calculate the number of pupils who are in the remaining smaller group. The output of the program must be displayed as follows: There are 9 groups consisting of 6 pupils There are 3 remaining pupils Submit both your program and output Question 3 . You are requested to write a very simple calculator. Your calculator should be able to handle the five basic mathematic operations – add, subtract, multiply, divide and modulus – on two input values. Your 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. Question 4 4 The Computer Science Department follows certain criteria when a student learns to program. A number of programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate if a student can proceed to the next program. Your program should have the following structure: • Declare two integer variables programsDone and result. • Validate the data captured for the two variables using a while loop. • The loop should be repeated until the value of result is greater than or equal to 50 and the value of programsDone is greater than or equal to 5. • Display a message like "Good! You can now proceed to the next exercise" Submit both your program and output.

Show more Read less









Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
July 12, 2022
Number of pages
7
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COS1511
Assignment
1 2022
(Questions)

, COS1511/103/0/2022

1 Assignment 1: 2022 SUBMISSION:
Electronically via myUnisa
Please note that we automatically give five days extension for this assignment. It will be to
your own advantage to check after a few days whether the assignment has been registered on
the system. If you have not completed the assignment by the extension date, submit whatever
you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us,
because we will be aware of it. Simply submit it as soon as myUnisa is available again.

DUE DATE 20 April 2022

UNIQUE NUMBER 830138
EXTENSION There is an automatic extension until 25 April. You do
not need to phone or send an e-mail to request
automatic extension
TUTORIAL MATTER Study Guide, Lessons 1 – 16

CONTRIBUTION WEIGHT TO 20%
SEMESTER MARK
QUESTIONS Practical exercises



IS YOUR SOFTWARE INSTALLED?
Look at ‘Troubleshooting’ under ‘Using the software’ in file index.html on Disk2016.
If you struggle to install the software, please contact your e-tutor.

Question 1



Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the
screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the
keyboard.

For example, if the recipe needs 2 cups of flour the output displayed will be something like this
Please enter the factor to multiply the ingredients with : 4
Recipe name
Ingredients
// other ingredients
8 cups flour
Method

The program has the following structure:
• Declare an int variable named mFactor to store the value with which the quantity of each ingredient
must be multiplied.
• The program must make use of a cin statement to input a value from the keyboard and store it in
mFactor.
Submit both your program and output.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
DoctorReinhad Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
2131
Member since
4 year
Number of followers
1728
Documents
6004
Last sold
5 days ago
TOP SELLER CENTER

Welcome All to this page. Here you will find ; ALL DOCUMENTS, PACKAGE DEALS, FLASHCARDS AND 100% REVISED & CORRECT STUDY MATERIALS GUARANTEED A+. NB: ALWAYS WRITE A GOOD REVIEW WHEN YOU FIND MY DOCUMENTS OF SUCCOUR TO YOU. ALSO, REFER YOUR COLLEGUES TO MY ACCOUNT. ( Refer 3 and get 1 free document). AM AVAILABLE TO SERVE YOU ANY TIME. WISHING YOU SUCCESS IN YOUR STUDIES. THANK YOU.

3,6

300 reviews

5
130
4
48
3
55
2
17
1
50

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions