Starting from:

$35

CSE110- Assignment 3 Solved

Task 1:  

Write javacode of a program that reads a student’s mark for a single subject, and prints out “Pass” if the student got more than 50, and “You shall not pass” otherwise.

Task 2:  

Write javacode of a program that reads a student’s mark for a single subject, and prints out the corresponding grade for that mark. The mark ranges and corresponding grades are shown in the table below. Valid range of marks is 0 to 100. Print “Wrong Input” otherwise.

Task 3:

Write javacode of a program for finding area of a rectangle given height and width by the user.

Task 4:

Write javacode of a program that calculates the tax as follows:

No tax if you get paid less than 10,000
5% tax if you get paid between 10K and 20K
10% tax if you get paid more than 20K
NO TAX IF YOU ARE LESS THAN 18 YEARS OLD.
Hint: Take payment and age from user as inputs; then calculate tax and prints it.

Task 5:  

Write javacode of a program that finds the number of hours, minutes, and seconds in a given number of seconds. For example, how many hours, minutes, and seconds are there in 10,000 seconds?

Task 6:  

Suppose the following   expressions are used to calculate the values of L for different values of S:

L = 3000 −125S2       if S 100

             12000                                             

L =    4  S 2 14900if S >= 100

Write javacode of a program that reads a value of S and then calculates the value of L.

Task 7:

Write    javacode of a program that reads the values for the three sides x, y, and z of a triangle, and then calculates its area. The area is calculated as follows:    area   s(s − x)(s − y)(s − z)  where s is  x  y  z                                                                                               2                                                                                                                                                                                

Task 8:  

A leading newspaper pays all their freelance writers at a rate of Tk. 500 per published article. Write javacode of a program that will read the number of published articles for one writer, and print the totalmonthly fees for that writer.

Task 9:  

Write javacode of a program to find the largest among three different numbers entered by user.

Task 10:

Write javacode for the following:

Ask the user to enter the name of his favorite car.
Display the name of the user’s favorite car 4 times.
Example: If the user enters “Toyota”, your program should print the name Toyota 4 times.

Task 11: 

Assume there are two variables a and b. Take values of these variables from the user. For example, user gave following two values.

a = 721 b = 463

Then exchange / swap values in such a way so that printing the variable a gives 463 and b gives 721. Sample Input:

721

463

Sample output: Before Exchange:

a = 721 b = 463 After Exchange:

a = 463 b = 721

Task 12:  

Take value of a, b, c from the user. Then print in such a way that value of a goes to b

value of b goes to c

value of c goes to a

Task 13: 

Take value of a, b, c, d from the user. Then print in such a way that value of d goes to c

value of c goes to b value of b goes to a

value of a goes to d

Task 14:

Take a number from user and print its absolute value. If user gives minus five, print positive five. If user gives positive five, print positive five. No need to print plus sign.

Task 15: 

Take hour from the user as input and tell it is time for which meal.

User will input the number in 24-hour format say 14 to mean 2pm, 3 to mean 3am, 18 to mean 6pm etc.

Valid inputs are 0 to 23. Inputs less than 0 or more than 23 are invalid in 24-hour clock. Input will be whole numbers. For example, 3.5 will NOT be given as input.

Inputs: Message to be printed

4 to 6: Breakfast

12 to 13: Lunch

16 to 17: Snacks 19 to 20: Dinner

For all other valid inputs, say "Patience is a virtue"

For all other invalid inputs, say "Wrong time"

For example,

If the user enters 4, your program should print the message "Breakfast".

If the user enters 5, your program should print the message "Breakfast".

If the user enters 6, your program should print the message "Breakfast".

If the user enters 0, your program should print the message "Patience is a virtue".

If the user enters 1, your program should print the message "Patience is a virtue".

If the user enters 18, your program should print the message "Patience is a virtue".

If the user enters 23, your program should print the message "Patience is a virtue".

If the user enters 24, your program should print the message "Wrong Time".

If the user enters -1, your program should print the message "Wrong Time". If the user enters 27, your program should print the message "Wrong time".

Task 16: 

Write javacode of a program that reads an integer, and if the number is even and greater than 10, prints “An even number greater than 10”. If the number is even but lesser than 10, print “An even number not greater than 10”. If the number is greater than 10 but odd, print “An odd number greater than 10”. If the number is odd and also less than 10, print “An odd number less than 10”.

Task 17: 

Write javacode of a program that reads an integer, and prints the integer if it is a multiple of either 2 or 5.

For example, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22 …

Task 18:

Write javacode of a program that reads an integer, and prints the integer if it is a multiple of either 2 or 5 but not both.

For example, 2, 4, 5, 6, 8, 12, 14, 15, 16, 18, 22 …

Task 19: 

Write javacode of a program that reads an integer, and prints the integer if it is a multiple of 2 and 5. For example, 10, 20, 30, 40, 50 …

Task 20: 

Write javacode of a program that reads an integer, and prints the integer if it is a multiple of NEITHER 2 NOR 5.

For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 …

More products