KEMBAR78
Oxygen Plants Code Java | PDF | Computers | Technology & Engineering
100% found this document useful (2 votes)
4K views1 page

Oxygen Plants Code Java

This Java program calculates the number of plants needed and total oxygen produced for a given floor area and plant area. It takes floor and plant area sizes as input, calculates the total number of plants by dividing floor area by plant area, rounds to the nearest 10, and calculates total oxygen produced by multiplying number of plants by 0.9 liters per plant. The number of plants and liters of oxygen are then printed as output.

Uploaded by

Amulya Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
4K views1 page

Oxygen Plants Code Java

This Java program calculates the number of plants needed and total oxygen produced for a given floor area and plant area. It takes floor and plant area sizes as input, calculates the total number of plants by dividing floor area by plant area, rounds to the nearest 10, and calculates total oxygen produced by multiplying number of plants by 0.9 liters per plant. The number of plants and liters of oxygen are then printed as output.

Uploaded by

Amulya Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.text.

DecimalFormat;
import java.util.Scanner;

public class OxygenProduction {


private double floorArea;
private double plantArea;

public OxygenProduction(double floorArea, double plantArea) {


this.floorArea = floorArea;
this.plantArea = plantArea;
}

public int calculateTotalPlants() {


double totalPlants = (floorArea * 10000) / plantArea;
int roundedPlants = (int) Math.floor(totalPlants / 10) * 10;
return roundedPlants;
}

public double calculateTotalOxygen() {


int totalPlants = calculateTotalPlants();
double oxygenProduction = totalPlants * 0.9;
return oxygenProduction;
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
DecimalFormat decimalFormat = new DecimalFormat("0.00");

System.out.println("Enter the floor area of the room (m*m):");


double floorArea = scanner.nextDouble();

System.out.println("Enter the plant area of a single plant (in cm2):");


double plantArea = scanner.nextDouble();
scanner.close();

OxygenProduction oxygenProduction = new OxygenProduction(floorArea,


plantArea);
int totalPlants = oxygenProduction.calculateTotalPlants();
double totalOxygen = oxygenProduction.calculateTotalOxygen();

System.out.println("Total plants placed on floor area " +


decimalFormat.format(floorArea) + "*" +
decimalFormat.format(floorArea) + " is " + totalPlants + " plants
produces " +
decimalFormat.format(totalOxygen) + " litres of oxygen in a day");
}
}

You might also like