In: Computer Science
Write in java
Q 4.Centigrade and Fahrenheit are two scales to measure temperature. Write a program that that prompts the user to enter Centigrate and then print the Fahrenheit.
Use following formula for conversion.
Fahrenheit = Centigrade*1.8 + 32 ;
Q. 7 Write a program to calculate the bill of a customer. The program will
- Prompt the employee to enter the monthly plan fees.
- Prompt the employee to enter the rate per additional minute.
- Print the bill
The bill will be calculated as follows: if the number of consumed minutes is 300 minutes or less, the client pays only his regular monthly fees. If the number of minutes is more than 300, then he should pay in addition to the regular monthly fees, an extra amount for each additional minute consumed (over the allowed 300 minutes using rate per additional minute.).
Q4.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.println("Enter
Temperature in Centigrade"); //promt user to write temp in
centigrade
double Centigrade;
double Fahrenheit;
Scanner s= new
Scanner(System.in);
Centigrade = s.nextDouble();
Fahrenheit = Centigrade*1.8 + 32 ;
System.out.println("Temperature in
Fahrenheit"+Fahrenheit); //print temperature in fahrenheit
}
}
Q7.import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
System.out.println("Enter Monthly
plan fees"); //Promt employee to enter monthly plan
int mf=s.nextInt();
System.out.println("Rate per
additional minute"); //Prompt employee to write rate per extra
min
int rpam=s.nextInt();
System.out.println("No of Minutes
Consumed"); //Promt employee to write consumed time
int nmc=s.nextInt();
int money;
if(nmc>300)
{ int a=nmc-300;
money=mf+ a*rpam;
System.out.println("Please pay Rs.
"+money); //Print the bill
}
else
{ money=mf;
System.out.println("Please pay Rs.
"+money); //Print the bill
}
}
}