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
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.
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);
}
}
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...
Q: whats is the length of UDP?
A: The given User Datagram Protocol header is 12 03 00 0F 00 1E A3 10.The UDP (User Datagram Protocol) ...
Q: You are a new employee in the engineering organization of a large camping equipment and outdoor furn...
A: Successful implementation of Product Lifecycle Management (PLM) systemA PLM system is an information...
Q: Please Use JAVA to solve the problem
A: Create a java class “ArrayInv” and create a main method inside it.And declare a required variable to...
Q: What are the four components of php application and explain why these are so important?
A: Four components of a PHP application are the following:DatabaseHTMLSessions/Authentication/ CookiesU...
Q: How do I code this on python heres the problem Use the Design Recipe to define a function count_val...
A: Programming instructions: Define the function count_value which takes the list and a value as an arg...
Q: I dont understand whats going on Its hard for me to read whats happening and what the output will be...
A: Click to see the answer
Q: WRITE A SHORT NOTE ON THE PRIMITIVE COMPONENTS OF BITCOIN VALUE CHAIN?
A: Bitcoin Value Chain can be defined with the help of three terms BlockChain, Private Keys and third M...
Q: Assignment First, launch NetBeans and close any previous projects that may be open (at the top menu ...
A: Program: public class MultiTable{public static void main(String[] args){ int i, j; System.out.print(...
Q: Suppose s is a string with the value "java". What will be assigned to x if you execute the following...
A: Given:String s = “java”;char x = s.charAt(4);