Problem 4: Fibonacci Series always starts with 0 and 1, or in other words the first two terms of this series are 0 and 1. Next term in this series is found by adding two previous numbers. Following figure shows first 6 terms of the Fibonacci Series i.e. 0, 1, 1, 2, 3, 5, if we were to print only even numbers then the output will be 0, 2.
Design the algorithm (pseudocode) for a program that prints even terms in Fibonacci series less than N. Where N is the number entered by the user. For example,
If N is 75 then print 0, 2, 8, 34 (i.e. all even terms in Fibonacci series that are less than 20)
If N is 20 then print 0, 2, 8 (i.e. all even terms in Fibonacci series that are less than 20)
If N is 6 then print 0, 2 (i.e. all even terms in Fibonacci series that are less than 6)
Name Q1 Q2 Q3 Q4 Q5
Jean
Mark
Von 20
Ben
Jessie
Yno
Problem 3: A bookseller has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows:
If a customer purchases 0 books, he or she earns 0 points.
If a customer purchases 1 book, he or she earns 5 points.
If a customer purchases 2 books, he or she earns 15 points.
If a customer purchases 3 books, he or she earns 30 points.
If a customer purchases 4 or more books, he or she earns 60 points.
Write a pseudocode program that asks the user to enter the number of books that he or she has purchased this month and then displays the number of points awarded
Create a component that receives two numbers from the user through a Web Form, and
based on the user’s selection it adds or subtracts the two numbers and returns the result to
the Web Form. The result should be displayed in the Web Form.
Create a program that takes in a student’s full names and marks for 3 In-class exercises, then calculate the average of this marks. This average mark is then categorized as follows: Marks obtained Grade Level Message 80 – 100 1 Magnificent!!
70 – 79 2 Excellent!!
60 – 69 3 Good work!!
50 – 59 4 Good!!
0 – 49 0 Fail – Try again next Year!!
Greater than 100 or less than 0 X Invalid Marks!!, Marks too high. Or Invalid Marks!!, Negative marks not allowed.
Sample run 1: Enter student full names: Goodluck Johnathan Enter 3 marks separated by spaces: 78 94.6 88
Output: Student name: Goodluck Johnathan Grade Level: 1 Comment: Magnificent!! Sample run 2: Enter student full names: Ellen Johnson Sirleaf Enter 3 marks separated by spaces: 200 104.87 99.9
Output: Student name: Ellen Johnson Sirleaf Grade Level: X Comment: Invalid Marks!!, Marks too high
Create a program that takes in two words, check for equality ignoring the cases, if the words are equal the print the word in upper case with an appropriate message however if the words are different then print the two words in lower case with an appropriate message.
Sample run 1:
Enter two words separated by spaces: Welcome WELCOME
Output: You have only entered one word: “WELCOME”
Sample run 2: Enter two words separated by spaces: NUST Students
Output: You have entered two words: “nust” and “students”
Given any whole number from user input, check whether it’s a positive or negative number. If the number is negative then increment it by 3 and multiply the result by 4, however if it’s a positive number then decrement by 4 and multiply it by 3.
a) Create a flowchart to be followed to solve the above task
b) Create a java program using your flowchart and see samples below
Sample run 1:
Enter a whole number: 4
Output: The Number 4 is above zero hence,
Result of the calculations = 0
Sample run 2:
Enter a whole number: -5
Output: The Number -5 is below zero hence,
esult of the calculations = -8
I. Make use of a loop of your choice and write statement(s) that will display all array elements indicating the Municipality’s name as follows: (6)
Municipality 1: Steve Tshwete
Municipality 2: Nkomazi
etc
VenueControlClass
Code a method problemlab(). This method has no parameters and is void. This method displays all computer labs that have less working computers that number of seats. Expected output (take note of headings and other formatting): Problem computer labs Building name: Engineering Venue number: 1.35 Number of seats: 50 Number of working computers: 30 ------------------------- Building name: Engineering Venue number: 1.24 Number of seats: 40 Number of working computers: 35 ------------------------- 5 Applications Development Foundations I 8 Code the add() method as follows: 9 Code a method, menuControl() that is void. This method controls the application. Processing includes: Call the menu() method. Use a switch statement and depending on the option returned by menu(), it calls the appropriate method(). Refer to the menu() for the available options.
VenueControlClass
5. Code a method named createComputerLab().
Required: a. Define a Scanner variable to read from the keyboard. b. Define variables for building name, room number, number of seats and number of working computers. Prompt the user to type data values for each of the variables and read the values from the keyboard. c. Define and create a ComputerLab object from the data read from the keyboard. d. Return this ComputerLab object.
6. Code a method displayAllRooms(). This method has no parameters and is void. This
method displays all objects in the array. Required: a) Display a heading. 4 Applications Development Foundations b) Loop through the array and use the show() of every object to display the object details. c) Print a line after each object is displayed.