# Think of one of your Math homework. How can you use program to reveal the answer? Write a calculation program with atleast ten(10) variable statements calculating a problem

Question
69 views

Think of one of your Math homework. How can you use program to reveal the answer? Write a calculation program with atleast ten(10) variable statements calculating a problem

check_circle

Step 1

A program is to be created that uses at least 10 variables to calculate a problem. Let us consider a problem of calculating total sale of seven days, average sale and Percentage sale in a week. Here 10 variables will be declared as Mon, Tue, Wed, Thur, Fri, Sat, Sun, TotalSale, AvgSale and AvgPer.

Step 2

The following java program will calculate the problem.

import java. util.*;

public class Main

{

public static void main(String[] args)

{

// ten variables are declared

int Sun = 1000;

int Mon = 1500;

int Tue = 1200;

int Wed = 1800;

int Thur = 1500;

int Fri = 800;

int Sat = 900;

float TotalSale;

float AvgSale;

float AvgPer;

// Calculating total Sale

TotalSale = Sun + Mon + Tue + Wed + Thur + Fri + Sat;

System.out.println("Total Sale for the week is \$" + TotalSale);

// Calculating Average Sale

AvgSale = TotalSale/7;

System.out.println("Average Sale for the week is \$" + AvgSale);

// Finding Percentage Sale

AvgPer =(AvgSale/ TotalSale)*100;

System.out.println("Average Percentage Sale for the week is " + AvgPer);

}

}

Step 3

In the above program, 10 variables are declared as Mon, Tue, Wed, Thur, Fri, Sat, Sun, TotalSale, AvgSale and AvgPer. Then Total sale is calculated by adding sales for seven days and result is pr...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 