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

The Positive Ones


by CodeChum Admin



There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.





Go and search for the positive ones among these four!



Input



A line containing four numbers (may contain decimal places) separated by a space.



2·-4·3.6·1


Output



A line containing an integer.



3

Placement session begins code by using array and integer in java plz help


Input an integer n which denotes the no of students present



5. Negative Decimal Tally

by CodeChum Admin

We've been giving positive numbers too much attention lately, it's time to let negative numbers take the spotlight this time!


Instructions:

  1. Input four float numbers; they could be positive or negative.
  2. Only add all inputted negative numbers, and print its sum, up to 2 decimal place.
  3. Hint: The previous/latest topic is about if-else-elseif statements, but do we need one here?

Instructions

  1. Input four decimal numbers, they could be positive or negative.
  2. Add all the negative numbers, and print the sum, up to 2 decimal places.

Input

A line containing four decimals/floats separated by a space.

-30.22·10.5·-2.2·-1.8

Output

A line containing a negative decimal/floats with two decimal places.

-34.22

Write pseudo code that prints the smallest value among a list of numbers.


2. Write a subroutine named "printDayofWeek" that will output the day of the week for a given number. Use Swtich-case. For example, the command "1” would output “Sunday”.


3. The Car class (subclass) inherits the attributes and methods from the Vehicle class (superclass). And every car has model. Please also add toString method to the Car class to print out the brand, and model of the car.

Class Vehicle { protected String brand; Vehicle()

{

Brand = “Ford”; }

public void honk() { System.out.println("Tuut, tuut!");

} }

Please help write the Car class.


4. Try to refactor below codes for computing score (underlined part) with extract methods.

// Vehicle attribute

// Vehicle constructor

// Vehicle method

  public class Customer {

void foo() {

int a, b, c, xfactor;

int

}


4. Gathering Positivity

by CodeChum Admin

I always want to look at the positive side of things, so I decide to seriously look at positive numbers, too!


Will you code along with me?


Instructions:

  1. Using the do…while() loop, continuously scan for integers, but add up only all the positive integers and store the total in one variable.
  2. The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers.

Instructions

  1. Using the do…while() loop, continuously scan for random integers, but add up only all the positive integers and store the total in one variable.
  2. The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers.

Input

Multiple lines containing an integer on each.

2
3
4
-1
-5
1
0

Output

A line containing an integer.

10




int a = 5, b = 10, c = 16, d = 0;

What are the outputs after the following Java statements are executed?

(a) if ( d )

else

system.out.println( “true” ); system.out.println( “false” );

(b) if ( a != 5 || b = = 10 ) system.out.println( “true” );

else

system.out.println( “false” );

(c) if ( b <=a && c/d)

system.out.println( “true” );

else

(d) if (a > 5 || d) else

system.out.println( “false” );

system.out.println( “true” ); system.out.println( “false” );

(e) if ( a*d >= d++ )

system.out.println( “true” );

else

system.out.println( “false” );

(f) if (d/a < c*b )

system.out.println( “true” );

else

system.out.println( “false” );


4. Is It You, Cody?

by CodeChum Admin

Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct.


Now, will you take on this task?


Input

A line containing four one-letter strings separated by a space.

c·O·D·y

Output

A line containing a string.

Correct




8. Groupings

by CodeChum Admin

Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.


Instructions:

  1. Create a variable that accepts a positive odd integer.
  2. Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
  3. Reverse the order of the list. Then, print out the list's new order in this manner:
  4. [first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.

Input

The first line contains an odd positive integer.

The next lines contains an integer.

5
1
3
4
5
2

Output

A line containing a list.

[2,5]-[4]-[3,1]

class Tool {

private String name = "B tool"; public Tool(String name)

{

this.name = name; }

}

class Hammer extends Tool {

// Suppose Crackable interface exists public void crack(Crackable b)

{

// implementation to crack object b}

}

Will it compile? YES or NO. Give reason, if No.


package studentBase;

class Test

{

String greet = “Hi”;

String name = “Smedley”;

String nickName = name.substring (0,2); If (nickName == name.substring(0,2))

System.out.println(“has real nickname”);

else if (greet + name == greet + nickName);

System.out.println(“no real nickname”);

Else

System.out.println(“hmmm ... changed names?”); }

Will it compile? YES or NO. Give reason, if No.


LATEST TUTORIALS
APPROVED BY CLIENTS