Professional Documents
Culture Documents
Ahmed 570.700: Name: Ahmed Salary 570.700 Tax 28.535 Nat Salary 542.165
Ahmed 570.700: Name: Ahmed Salary 570.700 Tax 28.535 Nat Salary 542.165
Salary =570.700
Tax = 28.535
import java.util.Scanner;
public class ifstring {
public static void main(String[] args) {
Medium speed
Air 1,100 feet per seconds
Water 4,900 feet per seconds
Steel 16,400 feet per seconds
Sample input/output
Solution
import java.util.Scanner;
public class q2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double time=0;
String name;
double distance;
System.out.println("Enter medium and distanc");
name = input. Next();
distance = input.nextDouble();
if (name.equalsIgnoreCase("air"))
time = distance / 1100;
else if (name.equalsIgnoreCase("water"))
}
}
Q3:- write a program that asks a user to enter a temperature .The program then
prints a message describing the weather according to the following table :-
Temperature Message
T <10 COLD
10≤T<20 PLEASANT
20≤T<30 WARM
T≥30 HOT
Q4:- write a program that asks user to input a digit from 2 to 9.your program print corresponding letters
on mobile phone keyboard as shown in the table below:-
digit 2 3 4 5 6 7 8 9
Letters ABC DEF GHI MNO PQRS TUV WXYZ TEV
Q5_ Write program to calculate and output the net price of a pizza based on one
user input:
2- Size (S for small, M for medium, or L for large). The net price of pizza is the sum of the
follows:
2- Base price of the pizza is $8.50 for small, $10.50 for medium, and $12.50 for large. any
other type is $20.00
Q6:-A whole sale department is offering reduced price on large orders of kitchen utensils. Write
program to calculate and display the net price of an order based on three user inputs:
price(float) ,quantity (int) and payment method char :A for each in advanced, D for cash on
delivery). The net price of the order is calculated as follows: -
Discount1= 4% of price for quantities more than or equal to 1000 otherwise 2% of price.
Discount2=5% of price for cash in advance payment and no discount for cash on delivery.
Sample input/output
10 2500 A
import java.util.Scanner;
public class q2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int q;
double price, netprice, d1, d2;
char pa;
System.out.println("enter price and quantity and paymen");
price = input.nextDouble();
q = input.nextInt();
pa = input.next().charAt(0);
}
}
Q7: -mobile wallet is virtual wallet that stores payment card information on
mobile device. Write a program that asks user to enter three numbers: wallet
balance, mobile number. to pay money to (assume mobile number is exactly 8
digits). And the amount of money to pay and performs the following:
Price=85 Price=100
Conditional operator
WHAT IS THE OUPUTOF THE FOLOWING C++ CODE:-
int a=-4,j; 16
j=(a>=0?0:a*a)
System.out.println<(j};
WHAT IS THE OUPUTOF THE FOLOWING C++ CODE:-
else
Sytem.out.prinln(x);