The average age to obtain a driver’s licence is 18. Write a Java program where the user enters his / her age. If the age is greater than or equal to 18, the program must display using JOptionPane the following message, “you are old enough to apply for a driver’s licence”, else display the following message, “you are not old enough to apply for a driver’s licence”.
Write a guessing game in java
where the computer generates a secret integer, and the user has to guess the secret integer. After every guess the program tells the user whether their number was too large or too small. Pring “Bingo” and the secret integer if the guess matches. At the end the number of tries needed should be printed.
Hints: How to generate secret number:
1. Import the class java.util.Random
2. Make the instance of the class Random, i.e., Random rand = new Random()
3. Use nextInt(upperbound) generates random numbers in the range 0 to upperbound-1
How to form a Pseudocode and Flowcharts for a Vending Machine
Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate
Sample Run1
Enter two numbers: 3 15
Do you want another operation: Yes
Enter two numbers: 45 56
Do you want another operation: No
Output1: Sum = 119
Sample Run2
Enter two numbers: 33 150
Do you want another operation: Yes
Enter two numbers: -56 56
Do you want another operation: Yes
Enter two numbers: 58 15
Do you want another operation: Yes
Enter two numbers: 123 87
Do you want another operation: No
Output2: Sum = 466
Write a Java program that uses both recursive and non-recursive (iterative)
functions to print the nth value in the Fibonacci sequence by using these methods:
The output should be:
Enter value of i: 12
Fibonacci number 12 is 144. --> This is displayed through Iterative Method.
Fibonacci number 12 is 144 --> This is displayed through Recursive Method.
Planning in forms of Pseudocode and Flowcharts for a Vending machine
Body Mass Index (BMI) is one of the criteria that is used to calculate whether one is fit or not basing on a person’s height (m) and weight (kg). The criterion is very simple; if one’s BMI is 25 or greater, it signifies overweight. A BMI less or equal to 18.5 indicates underweight. Lastly, a BMI greater than 30 shows obesity.
You have been requested to create a program that that helps the Namibian Defence Forces’ (NDF) Captain to calculates the BMI of a person (BMI = weight/height2) and also determine whether the person has also completed running 10 km in the required time. Men should complete 10km in less than 60 minutes for them to be accepted. Women should do that under 80 minutes. Both males and females are accepted if their BMI is less than 25 and greater than 18.5. For 2018 intake, there are already 6 males selected and 1 female. The values for gender, mass and weight are enter by user inputs
Your task is to then create a java program that when given an acronym with its meaning plus some sentence, the program replaces the first occurrence of the acronym in the sentence with its meaning.
Sample run 1:
Enter an acronym and its meaning (separated by spaces): NUST Namibia University of Science and Technology
Enter a sentence: Welcome to my NUST. Output: Welcome to my Namibia University of Science and Technology.
Given a number N, create a 2D arrays with n rows and n columns. Now inspect the matrix pattern below and come up with a formula to populate the array for any give NXN matrix.
5 4 3 2 1
10 8 6 4 2
15 12 9 6 3
20 16 12 8 4
25 20 15 10 5