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
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:
Instructions
Input
A line containing four decimals/floats separated by a space.
-30.22·10.5·-2.2·-1.8Output
A line containing a negative decimal/floats with two decimal places.
-34.22Write 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
}
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:
Instructions
Input
Multiple lines containing an integer on each.
2
3
4
-1
-5
1
0Output
A line containing an integer.
10int 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” );
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·yOutput
A line containing a string.
Correctby 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:
Input
The first line contains an odd positive integer.
The next lines contains an integer.
5
1
3
4
5
2Output
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.