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

Create a short program that will print 123467.89 as currency using NumberFormat

Negative Allergy (JAVA)

by CodeChum Admin

Whole numbers are great, but I think we should also pay attention to decimal numbers, too.


So, how about we make a program that involves a lot of decimals?


Instructions:

  1. Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable.
  2. The loop shall only terminate for the following reasons:
  3. A negative decimal number is inputted (but still included in the total sum)
  4. The total sum reaches 100.0 or more

Instructions

  1. Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable.
  2. The loop shall only terminate for the following reasons:
  3. A negative decimal number is inputted (but still included in the total sum)
  4. The total sum reaches 100.0 or more

Input

Multiple lines containing float number on each.

1.1
1.2
1.3
1.4
-1.0

Output

A line containing a float number with two decimal places.

4.00

Create a class named Apartment that holds an apartment number, number of bedrooms, number of baths, and rent amount. Create a constructor that accepts values for each data field. Also create a get method for each field. Write an application that creates at least five Apartment objects. Then prompt a user to enter a minimum number of bedrooms required, a minimum number of baths required, and a maximum rent that the user is willing to pay. Display data for all the Apartment objects that meet the user’s criteria or an appropriate message if no such apartments are available. Save the files as Apartment.java and TestApartments.java

Even Out (JAVA)

by CodeChum Admin

You know, I was lying when I said the last time that numbers associated with 3 are my favorite, because the one I actually like the most in the world are even numbers! But to make things harder for you, you have to pick the even numbers from a range of two given numbers. Ha!

Now, let's try this one more time! 


Instructions:

  1. Input two integers in one line, separated by a space. The first integer shall represent the starting point, and the other, the ending point.
  2. Print out all even numbers that are within the range of the starting and ending point (inclusive or including the ending point).

Input

A line containing two integers separated by a space.

5·10

Output

A line containing integers separated by a space.

6·8·10

A Shorter Three (JAVA)

by CodeChum Admin

Numbers in threes are awesome! But the one last time was too lengthy to look at, so I just want to view it in a shorter but still readable format.


You okay with this task?


Instructions:

  1. Print out all numbers from 1 to 100 that is divisible by 3 using a for loop just like the last problem, but this time, with each number only separated by the space like that of the sample output.

Output

A line containing integers divisible by 3 separated by a space.

3·6·9·12·15·18·21·24...

There was a Three

by CodeChum Admin

I'm bored with just basic counting. How about we do some complex things this time? But I don't want to be associated with any number that's not divisible by 3.


Think you can handle this?


Instructions:

  1. Print out all numbers from 1 to 100 that is divisible by 3, each in separate lines, using a for() loop.

Instructions

  1. Print out all numbers from 1 to 100 that is divisible by 3, each in separate lines, using a for loop.

Output

Multiple lines containing an integer that is divisible by 3.

3
6
9
12
15
18
21
24
27
30
33
36
39
42
45
48
51
54
57
60
63
66
69
72
75
78
81
84
87
90
93
96
99

Factorials (JAVA)

by CodeChum Admin

For those of you who may not now, a factorial is a product of multiplying from 1 until the number. Now, you must make a program that will accept an integer and then print out its factorial using loops.

Are you up for this task?


Instructions:

  1. Input a positive integer.
  2. Using a for() loop, generate the factorial value of the integer and print out the result.
  3. Tip #1: Factorials work like this: Factorial of 5 = 1 * 2 * 3 * 4 * 5
  4. Tip #2: There's a special case in factorials. The factorial of 0 is 1.

Input

A line containing an integer.

5

Output

A line containing an integer.

120

1. FizzBuzz (JAVA)

by CodeChum Admin

Instructions:

  1. Input a positive integer in one line. This will serve as the ending point of your loop.
  2. Loop from 1 to the ending point (inclusive) and perform the following statements:
  3. If the number is only divisible by 3, print "Fizz"
  4. If the number is only divisible by 5, print "Buzz"
  5. If the number is divisible by both 3 and 5, print "FizzBuzz"
  6. If nothing is true in the previous conditions, skip the number

Instructions

  1. Scan a positive integer n and store it in a variable.
  2. Create a counter variable with a value of 1 and create a loop from counter to n.
  3. Print "Fizz" if the counter in the loop is divisible by 3, "Buzz" if the counter is divisible by 5, "FizzBuzz" if it is both divisible by 3 and 5.
  4. Skip the iteration if it is not divisible by 3 or by 5.

Input

A line containing an integer.

15

Output

Multiple lines containing a string.

Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz




Create a program using a Java console application name it "Alphabetizer". The program should ask the user to enter is name and surname.

Create a method called emptySpace () this remove space between the name and the surname (Use a regular expression "replaceAll"). The emptySpace() method also Count the number of characters within the newly created string (nameSurname) and return the total number of Characters .

The total number of characters (Name and Surname) should be the size of your arrayAlphabetizer (type integer). Populate your arrayAlphabetizer with a series of random numbers between 10 and 50.

Display all arrayAlphabetizer elements and they are corresponding indexes before executing the sort() method and after executing the sort(). Allow the user to enter a value from the arrayAlphabetizer element to search for.

Loop through the array until you find the value and replace that value with the character @.

 Print out arrayAlphabetizer with the replaced element..


  1. Input three integers.
  2. Print the integers in ascending order.


"IF ELSE - ELSE IF STATEMENT"


Input

A line containing three integers is separated by a space.

6 1 3

Output

A line containing three integers is separated by a space.

1 3 6
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS