Where's the Biggest One?
by CodeChum Admin
We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate the position of the largest among 5 numbers. There are only 4 possible cases for this mission:
- if the largest digit is the first digit, print "Leftmost"
- if the largest digit is the third digit, print "Middle"
- if the largest digit is the last digit, print "Rightmost"
- if none of the above is correct, print "Unknown"
Now, show me how far you've understood your lessons!
Input
A line containing a five-digit integer.
1·4·6·3·2
Output
A line containing a string.
Middle
Java practical 1
It has been realized that hackers have started hacking and changing the account detains of some banks, to stop this practice, you have been tasked to create a class called Abaaneke, your class should contain three private variables (deposit, oldBalance, newBalace) all of type float and a variable of type String (name of the account holder)
Your class should also have a method that takes three arguments – name of account holder, amount deposited and old balance. The method should add the deposit to the oldBalance and call it new balance.
Using the right setters and getters, initialize the private variables and call the method to display the following
a. Account holders name
b. Amount deposited
c. Old balance
d. And new balance
how to use the arraylist to record the module details in student class?
4.The system verify the username and password. If wrong username,
please show the error message: Wrong username, please check and the re-enter your username. If wrong password,
please show the error message: Wrong password, please check and re-enter your password.
Display message to ask the user input
User name and password validation
Display the error message.
use of loop so user could re-enter the username/password when wrong input
If successful login, display the summary of the student
Correct format
Full set of details included as shown in the example
display of modules details
calculation of average mark, average attendance, grade conversion and correct display of remark message
3.
1 student who passes all modules exam and attendance,
1 student who passes all modules exam but fails some attendance,
1 student who fails some module exam but pass all modules attendance,
1 student who fails some modules in both exam and attendance
use array to record the 4 student profiles
2.
In the main , ask the user for the inputs: student ID, student name, password, study mode, the name of programme the student has registered, the current level of the programme, number of modules they have enrolled in the current term, the module codes and names, attendance of each module and exam mark of each module for each student profile.
Display message to ask user inputs
use of Scanner for all inputs:
output format display:
student Name: Florence Cheng
Student id:10010005
Study mode: Part time
programme:
higher diploma in Computer Technology
Cerrent Level: Year 1
Number of modules take by the term : 4
Code Attendance Exam Mark Grade
cs101 100% 80 HD
cs102 69% 71 D
Average Mark:
Average attendance:
Final Grage:
Remark: you need to retake some modules.
1.Create a Student Class to store the profile data including: student ID, student name, password, study mode.......
Create a Student class
Variables to store in profile data
Use array list to record the module details (module code, module name, mark, and attendance)
setter for each variable in the Student class with data validation
getter for each variable in the Student class
constructor for the Student class
Q.1.1 Create a two-dimensional array to contain the three sale items for five different artists. A single array must be used to store the artist names.
ARTIST NAME CD SALES DVD SALES BLU RAY SALES
Ed Sheeran 900 000 800 000 500 000
Pink 700 000 500 000 500 000
Bruno Mars 800 000 100 000 50 000
Foo Fighters 100 000 200 000 200 000
Taylor Swift 300 000 100 000 50 000
Q.1.2 Allow a user to enter in a number, ranging from 1 to 5, which will represent the artist position with regards to the album sales.
Q.1.3 Printout the artist name including the CD, DVD, BLU RAY sales amounts and total sales.
program that computes the area of either a rectangle, a circle or a right-angled triangle. The program should display a menu that enables the user to select the type of figure whose area he/she wants to compute. Depending on the user’s choice, the program should prompt for the dimensions and perform the computations. The output should be: - The type of figure, the dimensions and the area. Define three functions: - one to compute the area of a rectangle, one the area of a circle and one the area of a triangle. NB: 1. The calculation should be for only one figure at any one time.
2. Computations should be done in the user-defined functions.
Survival of the Biggest
by CodeChum Admin
Looping a number and taking away each digit of it is so much fun, but I wanted to try out a much more complex task: getting the largest digit among them all.
Think you can handle the job?
Instructions:
Input a non-zero positive integer.
Using the same concept as the previous problem, figure out how to separate the digits of a number and determine which of the digits is the largest one, using a while. Afterwards, print the largest digit.
Tip #1: Create another variable that will hold the largest digit. Initial its value to a negative integer, like -1, outside the loop.
Tip #2: Everytime you get the rightmost digit, check if it is greater than the current largest digit. If it is, set it as the new largest digit.
Input
A line containing an integer.
214
Output
A line containing an integer.
4