Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE IN JAVA Question 1 : Write a Java program that takes an input in feet and converts it to inches. If the input is

WRITE IN JAVA
Question 1: Write a Java program that takes an input in feet and converts it to inches. If the input is less than 0, print "Invalid input," otherwise, print the equivalent length in inches.
Example:
If feet =-3 : Print Invalid
If feet =6.3: Print 75 inches
Question 2: Take 3 numbers as input from the user and print the biggest and the smallest numbers.
Example:
Input:
num1=4
num2=3
num3=7
Output:
Biggest number =7
Smallest number =3
Question 3: Write a Java program that takes an integer number from the user and prints "Positive" if the number is greater than 0, "Negative" if the number is less than 0, and "Zero" if the number is 0.
Example:
Input: num =1| Output: Positive
Input: num =-4| Output: Negative
Input: num =0| Output: Zero
Question 4: Create a Java program that assigns a grade based on the score of a student. If the score is above 90, print "A". If the score is between 80 and 90(inclusive), print "B". If the score is between 70 and 79(inclusive), print "C". If the score is between 60 and 69(inclusive), print "D". Otherwise, print "F".
Example:
Input: score =92| Output: A
Input: score =85| Output: B
Input: score =76| Output: C
Input: score =65| Output: D
Input: score =59| Output: F
Question 5: Develop a Java program that acts as a simple calculator. The program takes three inputs: two double values a and b, and a char operator. Depending on the value of operator ('+','-','*','/'), the program should print the result of the operation between a and b. If the operator is not one of the specified characters, print "Invalid operator".
Example:
Input: a =5, b =3, operator ='+'| Output: 8.0
Input: a =10, b =2, operator ='/'| Output: 5.0
Input: a =8, b =2, operator ='%'| Output: Invalid operator
Question 6: Create a Java program for a retail store that applies discounts based on the purchase amount. If the purchase amount is greater than $1000, apply a 10% discount. For amounts between $500 and $1000(inclusive), apply a 5% discount. Otherwise, no discount is applied. Print the final amount after applying the discount.
Example:
Input: purchaseAmount =1500| Output: Final Amount: $1350.0
Input: purchaseAmount =750| Output: Final Amount: $712.5
Input: purchaseAmount =400| Output: Final Amount: $400.0
Question
7: Develop a Java program that acts as a simple calculator. The program takes three inputs: two double values a and b, and a char operator. Depending on the value of operator ('+','-','*','/'), the program should print the result of the operation between a and b. If the operator is not one of the specified characters, print "Invalid operator".
Example:
Input: a =5, b =3, operator ='+'| Output: 8.0
Input: a =10, b =2, operator ='/'| Output: 5.0
Input: a =8, b =2, operator ='%'| Output: Invalid operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago