Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I write a condition that checks if a String called s has at least 2 characters?

also how do I do the rest of this >>
Write a condition that checks if a String called s has at least 2 characters in it

Write a condition that checks whether String a and String b are identical from the 2 nd character to the 5 th
character ignoring case

Conditions/ifs:

Write an if/else statement that prints “Awesome!” if a variable called number is a multiple of 5 but not
9, or greater than 1000 and prints “Lame!” otherwise

Switch:
Write a switch statement that switches based on a String called alert.
If alert equals “red” it should print “Ohh no”
If alert equals “yellow” it should print “Stay calm”
If alert equals “green” it should print “We’re ok”
And it should say “I guess cannibalism is ok now” if alert equals anything else

Primitives and reference values:
Name 3 primitive integer types, and 2 primitive floating number types, and one primitive type that is
neither

int[] arr = {1, 2, 3};
arr2 = arr;
arr2[1] +=6;
What does arr equal now? __ __ __

Classes/Methods:
Create a Student class with two fields: a String called name and an int called grade. Make a constructor
that takes two arguments and initializes the fields with the arguments. Make a method called practice
that increases the grade by 10 and returns the new grade.

Have a main method in your class:

public static void main(String[] args){

}
and inside it make a Student object, use the practice method on it, and print out the new grade.

Arrays/ loops:

Create an integer array called nums and initialize it so it can hold 100 things.

Create a static function that takes an int array argument and checks all the values to see if any are 13. It
returns true if it finds a 13 and false otherwise and should work on an array of any length

Create a for statement that counts backwards from 20 counting by 5s

What I have tried:

I've tried everything and I just don't understand it...please help, I need to know these questions fro they will be asked in class tomorrow...HELP
Posted
Updated 24-Oct-18 22:20pm
Comments
_Asif_ 25-Oct-18 0:49am    
Show us the code you have tried, it seems you are asking us to do your homework :)

Quote:
also how do I do the rest of this
Right up to there, I was willing to help. Even eager.
But now? No.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

And if you can't even check the length of a string on your own, then you need desperately to re-read your course notes so far and learn at least the basics before you get to this exercise. Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900