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

Mani Wrapper Class

Coding

Uploaded by

naveen261005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Mani Wrapper Class

Coding

Uploaded by

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

DEMONSTRATE OF WRAPPER CLASSES

IN JAVA

SOURCE CODE :

import java.util.Scanner;
public class Business
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the total sales in dollars:");
Integer sales = scanner.nextInt();
System.out.println("Enter the total expenses in dollars:");
Double expenses = scanner.nextDouble();
System.out.println("Enter the previous sales in dollars for revenue growth calculation:");
Integer previousSales = scanner.nextInt();
Double profit = calculateProfit(sales, expenses);
Double revenueGrowth = calculateRevenueGrowth(sales, previousSales);
displayReport(sales, expenses, profit, revenueGrowth);
scanner.close();
}
public static Double calculateProfit(Integer sales, Double expenses)
{
return sales.doubleValue() - expenses;
}
public static Double calculateRevenueGrowth(Integer currentSales, Integer previousSales)
{
if (previousSales == 0) return 0.0;
double growth = ((currentSales - previousSales) / (double) previousSales) * 10;
return growth;
}
public static void displayReport(Integer sales, Double expenses, Double profit, Double
revenueGrowth)
{
String formattedRevenueGrowth = String.format("%.0f", revenueGrowth);
System.out.println("\n---- Business Report ----");
System.out.println("Sales: $" + sales);
System.out.println("Expenses: $" + expenses);
System.out.println("Profit: $" + profit);
System.out.println("Revenue Growth: " + formattedRevenueGrowth + "%");
}
}

You might also like