Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Discuss the difference between a PRETEST and POSTTEST loop. Briefly explain parallel arrays. What does immutable refer to? Given the following coding. private String


image text in transcribed imageimageimageimageimageimageimageimage

Discuss the difference between a PRETEST and POSTTEST loop. Briefly explain parallel arrays. What does immutable refer to? Given the following coding. private String GenerateStars(int x) { } String stars = ""; if (SALES[x]>=100) stars="****" } else{ } stars="**"; return stars; Explain the if statement. Discuss any two ways in which you could improve a loop performance. Q.5.3 Q.5.4 Q.5.5 Q.5.6 Write code to declare an array that will hold calendar months (.e. January to December). Take note: no need to do it practically using a compiler, just basic coding to declare an array and load calendar months as per question. Briefly explain what actual parameters are. consists of programming statements that have been compiled into binary format. (4) to encapsulate a series of statements. (2) (2) is the programming feature that allows you to use a method name (2) Q.3.1 Explain why an out of bounds error message may be generated when using arrays. Q.3.2 Distinguish in your own words between a sequence structure and a decision structure. Q.3.3 In programming terms, what is a token? Q.3.4 What are the four keywords used in a Switch Statement? Q.3.5 Explain what a Run-Time Error is. (2) (4) (2) (4) (2) Q.3.6 What does the following code output? int x = 8; int y = 2; while(x > 8) { X--; y+=2; System.out.println(y); } Q.3.7 What does the following code output? System.out.println((2 + 3 - 5) * (3/3) + (5+5)); Q.3.8 What does the following code output? if((2 == 2) && (3 != 3) && ((5 +1)==6)){ System.out.println(true); } else { } System.out.println (false); (2) (2) (2) Question 4 (Marks: 20) Debug the section of code that follows. Check the code carefully for all errors and list the line numbers, the errors and write the corrections to the errors as well. public class Watches { private WatchMake; private string SalesPerson; private double WatchPrice; Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 Line 11 Line 12 Line 13 Line 14 Line 15 Line 16 Line 17 Line 18 Line 19 Line 20 Line 21 Line 22 } public Watches(String make String sales Person, double price) { WatchMake = make; SalesPerson = salesPerson; WatchPrice = price } public String getWatch { return WatchMake; } public double getWatchPrice() { send WatchPrice; } public double getCommission(){ double pay_out >> 0.0; pay_out= WatchPrice *= 0.10; return pay out; Q.4.2 Q.4.3 Q.4.4 Q.4.5 Q.4.6 Explain the two parts that every method in Java must consist of. Distinguish between a sequence structure and a decision structure. When is a Switch Statement useful in programming? consists of programming statements that have been compiled into binary format. S 4 encapsulate a series of statements. (5) (4) (2) (2) is the programming feature that allows you to use a method name to (2) Question 5 Write the answers to the following questions. Q.5.1 Write short Java code to display the following screen (no need to do it practically (5) using a compiler, just basic coding to display the screen): Sample screenshot Q.5.2 TOP PROGRAMMING LANGUAGES APPLICATION Enter programming language 1: Java Enter the percentage of market usage for Java: 60 Enter programming language 2: C# Enter the percentage of market usage for C#: 25 Enter programming language 3: Python Enter the percentage of market usage for Python: 15 (Marks: 60) Explain the two parts that every method in Java must consist of. (5) Q.5.7 Write a method that calculates and returns an average as depicted in the following figure. The Independent Institute of Education (Pty) Ltd 2020 20 SALON SALLY SALON REPORT Jan >> 58 (2 4960.0) Jab >> 54 (2 6480.0) Mar 66 (R 7800.0) Apr 42 (R 6040.0) May 77 (2 9240.0) Jun >>49 (R 5000.0) Jul 5 (R 6600.0) Aug Sep Oct >> 53 (R 6360.0) Nov 60 (R 8160.0) Dec >> 2 (R 7440.0) 51 (R 120.0) 70 (R 0400.0) 12 CUSTOMER COUNT: AVERAGE CUSTOMERS: 59 (10) Page 10 of 13 2020 Q.5.8 Write short Java code to display the following screen (no need to do it practically (5) using a compiler, just basic coding to display the screen): Sample screenshot Input ? Enter (1) to display the vowel count. Enter (2) to display the non vowel count. Enter (0) to exit. OK X Cancel

Step by Step Solution

3.54 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing a business risk appraoch

Authors: larry e. rittenberg, bradley j. schwieger, karla m. johnston

6th Edition

9780324645095, 324645090, 978-0324375589

More Books

Students also viewed these Programming questions