0% found this document useful (0 votes)
47 views10 pages

Ppa115d_tro115d_fa2 2024s1 Paper Moderated

This document outlines the details for the Formative Assessment 2 for the Programming Principles course, including instructions for candidates, assessment structure, and specific questions to be answered. The assessment consists of multiple sections, including true/false, multiple choice, short questions, and programming tasks, with a total duration of 3 hours. Special requirements for the assessment include the use of calculators and other materials, and candidates are instructed to submit their answers electronically via the Electronic Campus platform.

Uploaded by

ninja9samurai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views10 pages

Ppa115d_tro115d_fa2 2024s1 Paper Moderated

This document outlines the details for the Formative Assessment 2 for the Programming Principles course, including instructions for candidates, assessment structure, and specific questions to be answered. The assessment consists of multiple sections, including true/false, multiple choice, short questions, and programming tasks, with a total duration of 3 hours. Special requirements for the assessment include the use of calculators and other materials, and candidates are instructed to submit their answers electronically via the Electronic Campus platform.

Uploaded by

ninja9samurai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

YEAR: 2024

SEMESTER: 1
ASSESSMENT: Formative Assessment 2

SUBJECT NAME: Programming Principles


SUBJECT CODE: PPA115D/TRO115D
QUALIFICATION(S): DPIF20/DPMC20/DPRS20/DPIT20

PAPER DESCRIPTION: Computer DURATION: 3 HOURS PAPER: ONLY


Based

SPECIAL REQUIREMENTS
 NONE
 NON-PROGRAMMABLE POCKET CALCULATOR
 SCIENTIFIC CALCULATOR
 COMPUTER ANSWER SHEET
 GRAPH PAPER
 DRAWING INSTRUMENTS

OTHER:

INSTRUCTIONS TO CANDIDATES: ANSWER ALL QUESTIONS

CHECK EACH SECTION OR QUESTION FOR ADDITIONAL


INSTRUCTIONS

TOTAL NUMBER OF PAGES INCLUDING COVER PAGE: 15

TOTAL NUMBER OF ANNEXURES: 0

EXAMINER: Miss VM Booi FULL MARKS: 80


MODERATOR: Mr M. Liebenberg TOTAL MARKS: 80
STUDENT TOTAL: ___
STUDENT %: ___
INSTRUCTIONS ON HOW TO WRITE THE TEST ON ELECTRONIC CAMPUS (EC):

1. Create a folder on D:\ Drive and rename the folder your student number.
2. Save all your work in the folder you have created
3. Open a text editor (notepad++ is recommended) or MS Word and save your document in your
student number folder.
4. Open the browser.
5. Type http://ec.tut.ac.za in the address field of the browser and press enter.
6. Click Login.
7. Type in student number for username and your tut4Life password.
8. Click Login button.
9. Click [Continue]
10. Select [Student]
11. Select [Tests]
12. Select [Webtest 4]
13. Type or Select PPA115D/TRO115D into the first text field.
14. Type or Select 20241 into the second text field.
15. Type or Select J into the third text field (The “J” must be a capital letter).
16. Click "Next"
17. Click on the "Write" button.
18. Click on "[Start]" and you will be in the test to submit your answers.
19. Click on [Section] on the test to submit each Questions and click [Go] to submit your answer-
Copy your answer and paste it in the space provided.
20. Click [Test] to move to the next or previous Questions.
21. Under each question click edit to update your answer.

1
PPA115D/TRO115D FA2 20241
QUESTION 1 [6]

True/False

Instructions
Log on to EC and proceed to the correct test. Select section 1 and provide your answers to this
question therein.

Completion time: 10 Minutes

STATEMENT

1.1 In a counter control loop, the loop continues until a certain condition is met.

1.2 The purpose of logical operators in programming is to compare two values or expressions
and determine the relationship between them.

1.3 In a switch statement in Java, if the break statement is omitted in a case block, the code
associated with the matching case executes, and the code in subsequent cases until a
break statement is encountered or the end of the switch statement is reached.

1.4 The body of a pre-test loop may never execute if the loop condition is initially false.

1.5 The declaration of a local variable in a method can appear anywhere in that method.

1.6 The following statements are equivalent.

2
PPA115D/TRO115D FA2 20241
Question 2 [6]

Multiple Choice
Instructions
Log on to EC and proceed to the correct test. Select Section 2 and provide your answers to this
question therein.

Completion time: 10 Minutes


2.1 Which control structure is used to execute a block of code based on the result of a logical
condition?
a. for loop
b. if statement
c. while loop
d. switch statement.

2.2 What is the correct order of precedence (from highest to lowest) for the following types of
operators in Java?
a. Logical, relational, arithmetic
b. Relational, logical, arithmetic
c. Arithmetic, relational, logical
d. Arithmetic, logical, relational

2.3 Which of the following statements is a valid if statement in Java?


a. if(amount>50)
b. if(amount=50)
c. if amount>50
d. All of the above are correct.

2.4 The logical operator AND operator (&&) in Java, _________________.


a. returns true if both operands are true, otherwise false.
b. returns true if either or both operands are true, otherwise false.
c. returns true if at least one operand is true, otherwise false.
d. returns false if both operands are true, otherwise true.

2.5 Which of the following statements does not correctly describes the components of a for loop in
Java?
a. The loop condition is evaluated after each iteration.
b. The loop body is mandatory.
c. The initialization statement is executed after the loop body.
d. The update statement is optional.

2.6 Which of the following statements correctly describes the use of a switch statement in Java?
a. A switch statement is used to execute a block of code repeatedly until a condition is met.
b. A switch statement is used to execute a block of code only if a specified condition is true.
c. A switch statement is used to execute one block of code from multiple possibilities based on
the value of an expression.
d. A switch statement is used to define and initialize variables.

3
PPA115D/TRO115D FA2 20241
Question 3 [12]

Short Questions

Preparations
• Open Microsoft word or notepad and type in your answers therein.
• Question 3.1 to Question 3.3 answer must be typed onto this notepad/word document.
• Submit each question under the slot/section provided on EC.
• Make sure you submit your answers whenever you are done with a question.

Instructions:
• Log on to EC and proceed to the correct test. Select Section 3 and provide your answers to this
question therein.
• Remember not to code the solutions for this question using an Editor as they will consume a lot of
your time. Provide only the required structure as instructed by the question.

Completion time: 20 Minutes

3.1 Write only the required simple-if for the following using the Java syntax for each.
3.1.1 Determine if the value of the results is 75. The value is stored in a variable called results. (2)
3.1.2 Determine if a student qualifies to be a mentor. To be a mentor, the students must be in their
second year (2) of study and have an average of at least 80% for all subjects. The input values
are stored in variables called yearOfStudy and average respectively. (2)
3.1.3 Determine if the remainder of valueA divided by valueB is greater than valueC. (2)
3.2 Write only the required statement(s) for the following using the Java syntax for each.
3.2.1 Write a for-loop in Java that has an initial value of 3, a final value of 25 and an increment of
2. The counter control variable must be stored in a variable called counter. (2)
3.2.2 Re-write the for-loop above in 3.2.1 in descending order. (2)

3.3 In your own words, what happens to a loop without an update to the counter control variable. (2)

4
PPA115D/TRO115D FA2 20241
Question 4 [16]

Selection Control Structure: Switch


Instructions
Log on to EC and proceed to the correct test. Select Section 4 and provide your answers to this
question therein.

Preparations
• Create a folder in the D drive called “D:\My Documents\StudentNumber\Question4\”, where
StudentNumber is your actual student number.
• Create a new file in Notepad++ called “MealCostApp.java”. Open the file and complete the
question as instructed below.

Completion time: 20 Minutes

Meal Cost Application


Develop a Java application that will prompt the user for the meal cost in Rands. Allow the user to add
extra sides to the meal. Determine total meal cost using extra side costs using the table below. Use a
switch to determine the total cost. Display the output as indicated in Figure 4.1 to Figure 4.3.

Table 4.1: Extra Sides Menu


Extra Sides Options Cost
1/F R 15.99
2/S R 22.55
3/C R 18.55
0 No extras
Any other option Invalid Choice for extras

Sample Output

Figure 4.1: Extra side Option 1

Figure 4.2: Extra side Option 2 (S)

5
PPA115D/TRO115D FA2 20241
Figure 4.3: Invalid Choice

6
PPA115D/TRO115D FA2 20241
Question 5 [10]

Iteration Control Structure: Pre-test Loop


Instructions
Log on to EC and proceed to the correct test. Select Section 5 and provide your answers to this
question therein.

Preparations
• Create a folder in the D drive called “D:\My Documents\StudentNumber\Question5\”, where
StudentNumber is your actual student number.
• Create a new file in Notepad++ called “PatternGeneratorApp.java”. Open the file and complete
the question as instructed below.

Completion time: 20 Minutes

Pattern Generator Application


Students in Grade 5 want to find different patterns for their mathematics project. They want to know
how to generate patterns using a Java application. Below is an example of a pattern they are given as
an example.

Write a Java program that will help them generate patterns. The patterns must have 10 numbers in the
series and the starting number for the pattern can be any random number from 1 to 10.
NB: Use the Random class to generate the starting number.

Sample Output

Figure 5.1

Figure 5.2

Figure 5.3

7
PPA115D/TRO115D FA2 20241
Question 6 [30]
Selection Control Structure
Preparations
• Create a folder in the D drive called “D:\My Documents\StudentNumber\Question6\”, where
StudentNumber is your actual student number.
• Create a new file in Notepad++ called “WaterTariffApp.java”. Open the file and complete the
question as instructed below.

Completion time: 140 Minutes

Water Tariff Application


Just Metering is a new utility management service to multi-tenanted premises around the City of
Tshwane. They provide services such as bulk electricity and water to their clientele. Currently, they want
a computerized system for their water usage services. They charge their customers an amount based on
different water usage categories as indicated in Table 6.1. The customer’s bill includes the
administration fee of R77.50 and the network charge of R154.80. This amount must be inclusive of 15%
VAT rate. Every financial year there is a tariff increase they need to add to customers’ accounts based
on the municipal rate increases. For the current year the increase is at 9.2% for all the water usage
categories. They want to automate this whole process in order to manage their account system.

Just Metering has requested your service to develop an application that will help generate an
invoice/bill for their clients.

Table 6.1 Water Tariff


Water Usage Category Current Tariff (excluding vat)
0 to 9 kl R0.00
10 to 18 kl R25.05
19 to 30 kl R39.02
More than 30kl R44.50

Develop a Java application that will help Just Metering to create an invoice for their clients. To
successfully do that, proceed as follows:
6.1 Develop a Java application class WaterTariffApp and save this in a file called WaterTariffApp.java.
6.2 Declare all necessary variables and constants.
6.3 Prompt the user for the following (See Figure 6.1):
6.3.1 The customer account number and
6.3.2 The water usage in kilolitres.

8
PPA115D/TRO115D FA2 20241
Figure 6.1: Prompting user input.

6.4 Determine the current water usage charge for each category using the information in Table 6.1
above.
6.4.1 If the water usage is a negative number, the program must display an appropriate error
message as shown in Figure 6.2.

Figure 6.2: Invalid water usage.

6.4.2 If the water usage entered is valid, calculate the following:


6.4.2.1 The new tariff increases for 2024.
6.4.2.2 The amount due, which must be inclusive of the admin fee and the network charge.
6.4.2.3 The amount due must be inclusive of the VAT rate.

6.5 Display the water bill account information as indicated below.

Figure 6.3: Display water bill account information

9
PPA115D/TRO115D FA2 20241

You might also like