Machine Problem in C++
Create a program that inputs the total amount of sales for the previous year then allows the user enter 12 double values(use array) representing stores sales for each month of the year. After all 12 values are entered, display each months sales amount and compare the total amount with the previous year then print a message indicating whether it is higher, lower, or equal from the previous year.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
/*
Machine Problem in C++
Create a program that inputs the total amount of sales for the previous year then allows the
user enter 12 double values(use array) representing stores sales for each month of the year.
After all 12 values are entered, display each month̢۪s sales amount and compare the total
amount with the previous year then print a message indicating whether it is higher, lower, or
equal from the previous year.
*/
#include <iostream>
#include <iomanip>
double SalesDate[12];
int i=0;
double total_sales_previous_year=0.00;
double total_sales_current_year=0.00;
int main()
{
std::cout << "Sales data for previous year\n";
std::cout << "----------------------------\n";
for ( i = 0; i < 12; ++i)
{
std::cout << "Enter sales for month " << i + 1 << " : ";
std::cin >> SalesDate[i];
total_sales_previous_year+=SalesDate[i];
}
std::cout << "\n\n";
std::cout << "The data for previous year you entered:\n";
std::cout << "---------------------------------------\n";
for (i = 0; i <12; ++i)
{
std::cout << "Month " << i + 1 << " " << SalesDate[i] << "\n";
}
std::cout << "\n\n";
std::cout << std::fixed << std::showpoint;
std::cout << std::setprecision(2);
std::cout << "Total Previous Year Sales PHP " << total_sales_previous_year;
std::cout << "\n\n";
std::cout << "Sales data for current year\n";
std::cout << "----------------------------\n";
for ( i = 0; i < 12; ++i)
{
std::cout << "Enter sales for month " << i + 1 << " : ";
std::cin >> SalesDate[i];
total_sales_current_year+=SalesDate[i];
}
std::cout << "\n\n";
std::cout << "The data for current year you entered:\n";
std::cout << "---------------------------------------\n";
for ( i = 0; i < 12; ++i)
{
std::cout << "Month " << i + 1 << " " << SalesDate[i] << "\n";
}
std::cout << "\n\n";
std::cout << std::fixed << std::showpoint;
std::cout << std::setprecision(2);
std::cout << "Total Current Year Sales PHP " << total_sales_current_year;
std::cout << "\n\n";
if (total_sales_current_year > total_sales_previous_year)
std::cout << "The current sales are higher than previous sales.\n";
else if (total_sales_current_year < total_sales_previous_year)
std::cout << "The previous sales are higher than current sales.\n";
else
std::cout << "The current sales are equal to the previous sales.\n";
return 0;
}
No comments:
Post a Comment