Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Place Values (JAVA)

by CodeChum Admin

Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more.


How about printing out each digit of a number starting from its rightmost digit, going to its leftmost digit?


Instructions:

  1. Input a non-zero positive integer.
  2. Using while loop, print out each digit of the inputted integer in separate lines, starting from its rightmost digit until the leftmost digit of the number.
  3. Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
  4. Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
  5. Tip #3: You'd have to repeat Tip #1 and Tip #2 inside the while() loop for this problem while the inputted integer is not yet 0.

Input

A line containing an integer.

214

Output

Multiple lines containing an integer.

4
1
2

Against All "Odds"

Instructions:

  1. Input a positive integer. This will serve as the starting point of the loop.
  2. Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line.
  3. Also remember that since the loop goes to descending order, a decrement variable shall be created and decreased per iteration for the loop to terminate when it reaches 0.

Instructions

  1. Scan an integer that will accept an integer greater than 0 and store it in a variable.
  2. Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line, just like that of the sample output.
  3. Also remember that since the loop goes to descending order, a decrement variable shall be created and decreased per iteration for the loop to terminate when it reaches 0.

Input

A line containing an integer.

10

Output

Multiple lines containing an integer.

9
7
5
3
1






Create enum for departments in an university – FINANCE, NETWORKS, EXAMINATION, are all departments of a university. Use the department enum in employee class. Traversed the department enum and prints the ordinal values. Enhanced enum with a new private instance variable deptCode holding the department code, a getter method for deptCode named getDeptCode(), and a constructor which accepts the department code at the time of enum creation


Create a simple library management system with the classes library,admin ,user,librarian,books,issue.

use instance methods such as getters, setters and constructors, for a library management system, your class should have functionality listed below:

  1. register_student
  2. login

a. add_new_book

b. book_details

c. issue_books

d. issued_books

e. return_books




Create a program using a console application name "DragonKiller". The program should ask the user to enter his/her name and surname. Create a method name RemoveSpace() to remove space between the name and the surname entered by the user. Count the number of characters within the newly created string (nameSurname). The total number of characters (Name and Surname) should be used as the size of your arrayDragon (type integer). Populate your arrayDragon with a series of odd random numbers between 10 and 50. Display all arrayDragon elements and their corresponding indexes before executing. The insertionSort method allows the user to enter a value from the arrayDragon element to search for and be removed (Killed). • Loop through the array until you find the value (Use the binarySearch to locate the value with in your array) and kill that value from the arrayDragon. By replacing the value findDragon with a Zero (0) • Print out arrayDragon with the killed element.



Design a program using a console application in java NetBeans, named studentMarksReport that will print the final result obtained by a student with the weighting of each module. Make use of a class named Student that contains variables to store the student number, test result, assignment result and exam. Create a constructor that accepts the student number, test result, assignment result and the exam result as parameters and create get methods for the variables (UseJOptionePane to get variable from the user). Create a subclass called Student_Report that extends the Student class. The Student_Report overrides all getter methods and the constructor from Students. Write code for the print_report method which calculates each assessment weighting as follows:

test =25% weighting

assignment=25%weighting

exam=50%weighting


1) Create a public class named: Employee that would get the firstname and lastname of each

employee from the keyboard/user

2) Create three objects: prog, adm and lib, for programmer, admin and librarian respectively to

access the properties in Employee class.

3) Create EmployeeSalary as parent interface to store basic_sal, housing_all and

transport_all. The values for these three items are fixed for all Employee and has abstract

function calculateSalary.

4) Create three sub classes namely: programmer, admin and librarian to store bonus,

overtime and total salary for each employee

5) Each of the constructor in (4) should inherit the properties of Employee(using the super

keyword) and implement the EmployeeSalary interface.

6) Hide the properties from the parent class Employee using encapsulation principle.

7) Use getters and setters to make the properties in Employee visible and accessible to other classes: programmer, admin and

librarian.



1) Create a public class named: Employee that would get the firstname and lastname of each

employee from the keyboard/user

2) Create three objects: prog, adm and lib, for programmer, admin and librarian respectively to

access the properties in Employee class.

3) Create EmployeeSalary as parent interface to store basic_sal, housing_all and

transport_all. The values for these three items are fixed for all Employee and has abstract

function calculateSalary.

4) Create three sub classes namely: programmer, admin and librarian to store bonus,

overtime and total salary for each employee

5) Each of the constructor in (4) should inherit the properties of Employee(using the super

keyword) and implement the EmployeeSalary interface.

6) Hide the properties from the parent class Employee using encapsulation principle.

7) Use getters and setters to make the properties in Employee visible and accessible to other


Write a program that declares and initializes an array of 7 integers. The program uses these static methods to perform different operations on the array:

void printArray(int[] arr) – takes the array as parameter and prints the array in horizontal order

int sumOfArray(int[] arr) – takes the array as parameter and returns the sum of the array

int getHighest(int[] arr) – takes the array as parameter and returns the highest value in the array

int resetArray(int[] arr) – takes the array as parameter and resets the value of each element to 0


Sample output:

Here’s the array: 

3 1 3 2 1 9 1

Sum: 20

Highest: 9

Here’s the array: 

0 0 0 0 0 0 0




LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS