Can someone help me solve this!
thx
Conditional structure , include also the console result.
1. Using switch case design and write a java application that takes as input a single letter and displays the corresponding digit on a telephone. The letters and digits on a telephone are grouped this way:

2=ABC
3=DEF
4=GHI
5=JKL
6=MNO
7=PQRS
8=TUV
9=WXYZ

The screen dialog might look like this:


Your code should display a message indicating that there is no matching digit for any non-alphabetic character entered by the user. Also, the application should recognize only uppercase letters. Include the lowercase letters with the invalid characters.
Prompt the user with an informative message for the input value, as shown on the above example. The application should include the input letter as part of the output. Use proper indentation, appropriate comment and meaningful identifiers throughout the code.
2. Using if…else, create a program that accepts a year in its four-digit form and determines if it’s a leap year. If the year is a leap year it should display the year and the phrase “is a Leap Year”, otherwise, the year and the phrase “is not a Leap year.”

3. Using nested if…else, write a program that reads a temperature as a whole number from the keyboard and outputs a probable season (winter, spring, summer, or fall) depending on the temperature.
• If the temperature is greater than or equal to 90, it is probably summer
• If the temperature is greater than or equal to 70 and less than 90, it is probably spring.
• If the temperature is greater than or equal to 50 and less than 70, it is probably fall.
• If the temperature is less than 50, it is probably winter.
• If the temperature is greater than 110 or less than -5, then you should output that the temperature entered is outside the valid range.

4. Using if…else, write a program that accepts three integer numbers and display them from highest to lowest.

5. Using nested if…else statement, create a program that accepts the gender the age and the salary of an individual. The program will display the salary exemptions of the individual. Use the table below for your reference.
Salary over But not over Age Over But not over Exemptions for Female Exemptions for Male
0 8000 13 18 0 0
8000 15000 18 25 2000.00 2500.00
15000 20000 25 30 4000.00 5000.00
20000 40000 30 35 6000.00 6500.00
40000 800000 30 65 10000.00 12000.00
Your program should also determine whether the inputs are invalid and should display appropriate message to show the user the invalid inputs.

Recommended Answers

All 12 Replies

What are your questions about the assignment that you posted?
What code have you written for it?

What are your questions about the assignment that you posted?
What code have you written for it?

can solve it?
using java...
package is scanner
using switch case statement...
thamk u..

Member Avatar for coil

The policy here is we don't do homework for other people. We can certainly help you debug and offer you ideas, but we won't write code for you.

1. That's not an "it", it's a them.
2. Yes, I'm pretty sure he can.
3. No, I'm pretty sure he won't.
4. You're welcome.... to post questions about your work. That is, questions, not requests for people to do your work for you. Your teacher gives you that assignment because he believes you can do it, and because he thinks you'll learn something from it. Give it a try - even failing, you'll learn more about Java than you will sitting around waiting for someone else to do it for you.

The policy here is we don't do homework for other people. We can certainly help you debug and offer you ideas, but we won't write code for you.

then help me then..
i need something that will help me easily to solve this problems above...
i will never forget u if u do that for me...
thank u...:idea:

I can help you debug your code. Here you go, the first problem: it doesn't exist. Fix that, and I'll help you more.

1. That's not an "it", it's a them.
2. Yes, I'm pretty sure he can.
3. No, I'm pretty sure he won't.
4. You're welcome.... to post questions about your work. That is, questions, not requests for people to do your work for you. Your teacher gives you that assignment because he believes you can do it, and because he thinks you'll learn something from it. Give it a try - even failing, you'll learn more about Java than you will sitting around waiting for someone else to do it for you.

oHH well...
thank u for your kind and consideration...
;D

that will help me easily

LAZY?

LAZY?

slight...^_^
i just cant concentrate on doing it... due to my severe headache...
and this assignment is to be passed this afternun...
ohh...
im just that stupid at all..
that i cant do nothing bout..
it...
hate it..
ughhh...

In that case, you should get out of programming and study management. If you want to be paid for lazy, you want to be a manager.

Member Avatar for coil

then help me then..
i need something that will help me easily to solve this problems above...
i will never forget u if u do that for me...
thank u...:idea:

Your assignments are not very hard. In fact, they're basic conditional statement drills. Assuming you already know the structure of conditional statements, you should be able to do this in less than half an hour. If you don't:

If Statement

if(boolean expression) {
	if the boolean expression is true this is executed
}
else if(other boolean expression) {
	if this is true, then this part is executed
	you can have as many of these as you want
}
else {
	if none of the above were satisfied, this is executed
}

While...Do While

while(boolean expression) {
	if expression is true then executes
	checks expression at the start of each run
}
when you get here, the while loop has terminated


do {
	this is executed at least once
	checks expression at the end of each run
}while(boolean expression);
when you get here, the do-while loop has terminated

Switch Case

switch(int variable) {
	case 0: if the int variable equals 0, this is executed	break;
	case 1: executed only if variable equals 1 	break;
	default: like the else in an if-else statement, executed if none of the above
				is executed
}
commented: Good stuff. Hope it takes. +1

Your assignments are not very hard. In fact, they're basic conditional statement drills. Assuming you already know the structure of conditional statements, you should be able to do this in less than half an hour. If you don't:

If Statement

if(boolean expression) {
	if the boolean expression is true this is executed
}
else if(other boolean expression) {
	if this is true, then this part is executed
	you can have as many of these as you want
}
else {
	if none of the above were satisfied, this is executed
}

While...Do While

while(boolean expression) {
	if expression is true then executes
	checks expression at the start of each run
}
when you get here, the while loop has terminated


do {
	this is executed at least once
	checks expression at the end of each run
}while(boolean expression);
when you get here, the do-while loop has terminated

Switch Case

switch(int variable) {
	case 0: if the int variable equals 0, this is executed	break;
	case 1: executed only if variable equals 1 	break;
	default: like the else in an if-else statement, executed if none of the above
				is executed
}

ohh.. .well thank u..!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.