0% found this document useful (0 votes)
3 views3 pages

ProgrammingDesignPrinciples (5N2927 Java)

The document outlines the Programming & Design Principles course for Summer 2024, including its component code and weighting. It consists of four structured questions covering various programming concepts, data types, loops, and methods, requiring candidates to answer all questions and use Eclipse. The questions assess knowledge on programming languages, IDE functions, data types, loops, and variable scope.

Uploaded by

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

ProgrammingDesignPrinciples (5N2927 Java)

The document outlines the Programming & Design Principles course for Summer 2024, including its component code and weighting. It consists of four structured questions covering various programming concepts, data types, loops, and methods, requiring candidates to answer all questions and use Eclipse. The questions assess knowledge on programming languages, IDE functions, data types, loops, and variable scope.

Uploaded by

ahmadyarbayat001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Component Name: Programming & Design Principles

Component Code: 5N2927


Session: Summer Year: 2024

Course: Computer Science


Weighting: 30%

Instructions to Candidates:
 4 Structured Questions
 Answer all Questions

 Use of Eclipse is allowed.

Page 1 of 3
Question 1
A. There are many programming languages with new ones appearing all the time. Give 2 reasons why we need more
than one programming language. (2 marks)
B. Identify three major functions of an IDE in modern programming. (3 marks)
C. What programming language would you use in the development of each of the following?
a. Coffee dispenser
b. Washing machine
c. Website
d. Finance System (4 marks)
D Clearly indicate the difference between machine code, low level languages and high level languages.
(6 marks)

Question 2

A. Give the most suitable data type for storing each of the following items of data:
(i) An IP address
(ii) Price of a bottle of water
(iii) Male or Female to be stored as M/F
(iv) Price of a house (2 marks)

B. Why would you have the line import [Link]; in a Java program. (2 marks)

C. What does the following program segment output? Show all your calculations.

short answer = 4 + 9 – 8 * 3 + 7 / 2 – 11 + 12 % 3 ;
[Link] (“The answer is “ + answer); (4 marks)

D. Write a program extract that will read in the number of units that a customer is buying and the price per
unit. If the customer is buying between 10 and 20 units inclusive, they get a discount of 20% on their order.
If they are buying more than 20 units, they are entitled to a discount of 25%. All orders are subject to VAT at
21% (after the discount, if any, has been deducted). The program should calculate the cost of the order and
output the number of units bought, the price per unit, the discount if any, the VAT amount and the overall
cost of the item. (7 marks)

Question 3

A. Give 2 differences between a for loop and a do while loop. Illustrate with an example. (2 marks)
B. What is the exact output of the following loops?
i. for ( byte i= 1; i<=11; i+=2)
[Link] (i+ “ “);
ii. for (float i=25; i>=8; i-=2.7)
[Link] (i); (3 marks)

Page 2 of 3
C. Show how a for loop may be used to count from 6 to 17 in increments of 1.4. (3 marks)

D: In 1627 Manhattan Island was sold to the Dutch settlers for approximately $24. If the proceeds of that sale
had been deposited in a Dutch bank paying 5% interest, compounded annually, what would the principal balance
be at the end of 2020?

Compound interest is calculated as:


Amount for year 1 = 24

amount for year 2 = amount for year 1 + (interest rate *amount for year 1)

amount for year 3 = amount for year 2 + (interest rate *amount for year 2)

etc.

Write a program extract that will initialise the cost of buying Manhattan, calculate the compound interest and the
amount that they would now have in their bank account and output this figure. (7 marks)

Question 4

A. Explain what is meant by the scope of a variable. (2 marks)


B. Write a method called isPunctuation that accepts a character and returns true if the character is a punctuation
mark (include full stop, comma, question mark, exclamation mark, semi colon and full colon as punctuation
marks), returns false otherwise. (6 marks)
C. Indicate how the method isPunctuation will be called. (2 marks)
D. Write a method called Cubed that will read in a real number and will output the cube of that number. Output
should be correct to 2 decimal places. (5 marks)

Page 3 of 3

You might also like