0% found this document useful (0 votes)
1 views

java_aat1

Uploaded by

faadilkhaleel360
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

java_aat1

Uploaded by

faadilkhaleel360
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

B.M.S.

COLLEGE OF ENGINEERING
(Autonomous college under VTU)
Bull Temple Rd, Basavanagudi, Bengaluru, Karnataka
560019 2023-2025
Department of Computer Applications

Report is submitted for fulfillment of AAT work in the subject

“Java
Programming”
By

FAADIL KHALEEL

Under the Guidance

Prof. R.V. Raghavendra Rao


(Associate Professor)
2. write a java program to calculate the taxation on electrical products.

import java.util.Scanner;

public class Tax {


public static void main(String[] args){
final double taxrate=0.15;
Scanner obj = new Scanner(System.in);
System.out.println("Enter the name of the electrical product");
String pname = obj.nextLine();
System.out.println("Enter the price of the product");
double pprice = obj.nextDouble();
double taxamt = pprice * taxrate;
double totalp = taxamt + pprice;
System.out.println("Product Name: " + pname);
System.out.println("Product Price" + pprice);
System.out.println("Tax Amount" + taxamt);
System.out.println("Total Price" + totalp);
}

Output :
3. write a java program to prepare the insurance premium of a particular person based on the
age,habits,and pre-medical check-up details.

import java.util.Objects;

import java.util.Scanner;
public class Insurance {

public static void main(String[] args){


int basepremium = 1000;
Scanner obj = new Scanner(System.in);
System.out.println("Enter your age");
int age = obj.nextInt();
System.out.println("Any habits that we must be aware of ? yes/no ?");
String habits = obj.next();
System.out.println("Any pre medical records ? Yes/no ?");
String premed = obj.next();
int agepre=0;
int habitsprem=0;
int premedprem=0;
if (age<25){
agepre=500;
}else if(age < 45){
agepre=1000;
}else if(age > 45){
agepre=1500;
}
if (Objects.equals("yes", habits)){
habitsprem=500;
}else{
habitsprem=0;
}
if (Objects.equals("yes", premed)){
premedprem=500;
}else{
premedprem=0;
}
int totalprem=basepremium+agepre+habitsprem+premedprem;
System.out.println("The total premium is"+ totalprem);
}

}
Output:
4. write a java program to suggest a person his/her BMI information with necessary
suggestions.

import java.util.Scanner;

public class BMIIndex {

public static double BMI(double height, double weight)


{
double bmi = weight / Math.pow(height, 2);
return bmi;
}

public static void main(String[] args)


{ Scanner obj = new Scanner(System.in);
System.out.println("Enter the height in meteres");
double height = obj.nextDouble();
System.out.println("Enter the Weight in kgs");
double weight = obj.nextDouble();

double bmi = BMI(height, weight);


System.out.print("The BMI is " + bmi + " so ");

if (bmi < 18.5)


System.out.print("underweight");

else if (bmi >= 18.5 && bmi < 24.9)


System.out.print("Healthy");

else if (bmi >= 24.9 && bmi < 30)


System.out.print("overweight");

else if (bmi >= 30)


System.out.print("Suffering from Obesity");
}
}
Output:
5. Write a java program to enable unit conversion as mentioned below.

• Km to miles vice-versa
• Kg to pounds vice-versa
• Celsius to fahrenheit vice-versa
• Cm to feet vice-versa
import java.util.Scanner;

public class UnitConvertion {


public static final double KM_TO_MILES = 0.621371;
public static final double KG_TO_POUNDS = 2.20462;
public static final double CM_TO_FEET = 0.0328084;

public static void main(String[] args) {


Scanner obj = new Scanner(System.in);

System.out.println("Unit Conversion Program");


System.out.println("1. Kilometers to Miles");
System.out.println("2. Miles to Kilometers");
System.out.println("3. Kilograms to Pounds");
System.out.println("4. Pounds to Kilograms");
System.out.println("5. Celsius to Fahrenheit");
System.out.println("6. Fahrenheit to Celsius");
System.out.println("7. Centimeters to Feet");
System.out.println("8. Feet to Centimeters");
System.out.print("Enter your choice (1-8): ");

int choice = obj.nextInt();


double input, result;

switch (choice) {
case 1:
System.out.print("Enter value in kilometers: ");
input = obj.nextDouble();
result = kmToMiles(input);
System.out.println(input + " kilometers is equal to " + result + " miles.");
break;
case 2:
System.out.print("Enter value in miles: ");
input = obj.nextDouble();
result = milesToKm(input);
System.out.println(input + " miles is equal to " + result + " kilometers.");
break;
case 3:
System.out.print("Enter value in kilograms: ");
input = obj.nextDouble();
result = kgToPounds(input);
System.out.println(input + " kilograms is equal to " + result + " pounds.");
break;
case 4:
System.out.print("Enter value in pounds: ");
input = obj.nextDouble();
result = poundsToKg(input);
System.out.println(input + " pounds is equal to " + result + " kilograms.");
break;
case 5:
System.out.print("Enter value in Celsius: ");
input = obj.nextDouble();
result = celsiusToFahrenheit(input);
System.out.println(input + " degrees Celsius is equal to " + result + " degrees
Fahrenheit.");
break;
case 6:
System.out.print("Enter value in Fahrenheit: ");
input = obj.nextDouble();
result = fahrenheitToCelsius(input);
System.out.println(input + " degrees Fahrenheit is equal to " + result + " degrees
Celsius.");
break;
case 7:
System.out.print("Enter value in centimeters: ");
input = obj.nextDouble();
result = cmToFeet(input);
System.out.println(input + " centimeters is equal to " + result + " feet.");
break;
case 8:
System.out.print("Enter value in feet: ");
input = obj.nextDouble();
result = feetToCm(input);
System.out.println(input + " feet is equal to " + result + " centimeters.");
break;
default:
System.out.println("Invalid choice.");
break;
}

obj.close();
}

public static double kmToMiles(double km) {


return km * KM_TO_MILES;
}

public static double milesToKm(double miles) {


return miles / KM_TO_MILES;
}

public static double kgToPounds(double kg) {


return kg * KG_TO_POUNDS;
}

public static double poundsToKg(double pounds) {


return pounds / KG_TO_POUNDS;
}

public static double celsiusToFahrenheit(double celsius) {


return (celsius * 9/5) + 32;
}

public static double fahrenheitToCelsius(double fahrenheit) {


return (fahrenheit - 32) * 5/9;
}

public static double cmToFeet(double cm) {


return cm * CM_TO_FEET;
}

public static double feetToCm(double feet) {


return feet / CM_TO_FEET;
}
}

Output:

You might also like