Contents: Click for quick access
36. Write a program to display volume of cuboid / box.37.Write a program to ask value in meter and convert into inch.38. Write a program to display total surface area and volume of hemisphere.39. Write a program to display area and perimeter of square.40. Write a program to display cost of painting the four walls of a room.41. Write a program to display simple interest.42. Write a program to input number as paise and convert into rupees only.43. Write a program to input selling price and cost price calculate profit or loss percentage.44. Write a program to input the day and display whether the day is Saturday or not?45. Write a program to ask quantity of pen, copy and pencil and their rate and find out the total amount.
I’ve included a list of some of the Java programs below. You may also view all of the Java programs on our mobile app. I strongly advise you to use our mobile app for a better experience.
Please click the link to get our app–> https://play.google.com/store/apps/details?id=com.allbachelor.javaapp&hl=en&gl=US
36. Write a program to display volume of cuboid / box.
import java.util.Scanner;
class VolumeOfCuboid {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the length of cuboid");
double length = sc.nextDouble();
System.out.println("Enter the breadth of cuboid");
double breadth = sc.nextDouble();
System.out.println("Enter the height of cuboid");
double height = sc.nextDouble();
double volume = length * breadth * height;
System.out.println("Volume of cuboid is " + volume);
}
}
37.Write a program to ask value in meter and convert into inch.
import java.util.Scanner;
class ConvertIntoInch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value in meter");
double meter = sc.nextDouble();
double inch = meter * 39.37;
System.out.println("Value in inch is " + inch);
}
}
38. Write a program to display total surface area and volume of hemisphere.
import java.util.Scanner;
class TsaAndVolumeOfHemisphere {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the radius of hemisphere");
double radius = sc.nextDouble();
double surfaceArea = 4 * Math.PI * (radius * radius);
double volume = (4.0 / 3.0) * Math.PI * (radius * radius * radius);
System.out.println("Surface area of hemisphere is " + surfaceArea);
System.out.println("Volume of hemisphere is " + volume);
}
}
39. Write a program to display area and perimeter of square.
import java.util.Scanner;
class PerimeterAndArea {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the side of square");
double side = sc.nextDouble();
double perimeter = 4 * side;
double area = side * side;
System.out.println("Perimeter of square is " + perimeter);
System.out.println("Area of square is " + area);
}
}
40. Write a program to display cost of painting the four walls of a room.
import java.util.Scanner;
class FourWalls {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the length of room");
double length = sc.nextDouble();
System.out.println("Enter the breadth of room");
double breadth = sc.nextDouble();
System.out.println("Enter the height of room");
double height = sc.nextDouble();
double cost = (length * breadth * height) / 500;
System.out.println("Cost of painting the four walls of a room is " + cost);
}
}
41. Write a program to display simple interest.
import java.util.Scanner;
class SimpleInterest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the principal amount");
double principal = sc.nextDouble();
System.out.println("Enter the rate of interest");
double rate = sc.nextDouble();
System.out.println("Enter the time period");
double time = sc.nextDouble();
double simpleInterest = (principal * rate * time) / 100;
System.out.println("Simple interest is " + simpleInterest);
}
}
42. Write a program to input number as paise and convert into rupees only.
import java.util.Scanner;
class Rupees {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the amount in paise");
double paise = sc.nextDouble();
double rupees = paise / 100;
System.out.println("Amount in rupees is " + rupees);
}
}
43. Write a program to input selling price and cost price calculate profit or loss percentage.
import java.util.Scanner;
class Perc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the selling price");
double sellingPrice = sc.nextDouble();
System.out.println("Enter the cost price");
double costPrice = sc.nextDouble();
double profit = (sellingPrice - costPrice) / costPrice * 100;
System.out.println("Profit or loss percentage is " + profit);
}
}
44. Write a program to input the day and display whether the day is Saturday or not?
import java.util.Scanner;
class Day {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the day");
int day = sc.nextInt();
if (day == 6) {
System.out.println("Day is Saturday");
} else {
System.out.println("Day is not Saturday");
}
}
}
45. Write a program to ask quantity of pen, copy and pencil and their rate and find out the total amount.
import java.util.Scanner;
class Pen {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the quantity of pen");
int pen = sc.nextInt();
System.out.println("Enter the price of pen");
int pricepen = sc.nextInt();
System.out.println("Enter the quantity of copy");
int copy = sc.nextInt();
System.out.println("Enter the price of copy");
int pricecopy = sc.nextInt();
System.out.println("Enter the quantity of pencil");
int pencil = sc.nextInt();
System.out.println("Enter the price of pencil");
int pricepencil = sc.nextInt();
double totalAmount = pen * pricepen + copy * pricecopy + pencil * pricepencil;
System.out.println("Total amount is " + totalAmount);
}
}