Hi, first of all, I apologise for anything wrong, a newbie around the corner. I had just started programming a few days ago so I wanted to try some programming to digest further.
I was wondering if I could return myself to the start of the program or a specific point of a program. So, I asked a question somewhere else and a solution the contributor came up with was class (I haven't go through that section prior to this). I looked up here (my primary source) and..couldn't understand much about it..
This is the code provided by contributor
Code:
int main()
{
MyClass* class = 0;
do{
class = new MyClass();
delete class; //important
//ask user to repeat
} while (userChoice == 'y');
return 0;
}
Code:
#include <iostream> //to let the compiler to see the cout
#include <cstdlib> //to let the compiler to see the rand()
#include <ctime> //to let the compiler to see the srand()
using namespace std;
int main()
{
cout << "Hello! To the future Businessmen/women! This is just a mock program for you to check your business skills \n\n";
cin.ignore();
cout << "Now, your shop has 3 items that are going to be sold and those are...\n";
cout << "1. USB (4.0 GB)" << "\n" << "2. Headphone (Stars)" << "\n" << "3. Logitech Optical Mouse \n";
cin.ignore();
cout << "And you have a capital of RM 5000" << "\n\n";
cin.ignore();
int USB, Headphone, Mouse;
float Capital, Price_USB, Price_Headphone, Price_Mouse, Cost_USB, Cost_Headphone, Cost_Mouse;
Capital = 5000.00;
Price_USB = 20.00;
Price_Headphone = 12.50;
Price_Mouse = 15.00;
cout << "So, before we begin our operations, may I ask how much stocks have you ordered for each items for this week?" << "\n\n";
cin.ignore();
cout << "For USB (4.0 GB) [The cost for 1 USB (4.0 GB) is RM " << Price_USB << " ] ? ";
cin >> USB;
Cost_USB = (USB)*(Price_USB);
cout << "\n\n";
cout << "For Headphone (Stars) [The cost for 1 Headphone (Stars) is RM " << Price_Headphone << " ] ? ";
cin >> Headphone;
Cost_Headphone = (Headphone)*(Price_Headphone) ;
cout << "\n\n";
cout << "For Logitech Optical Mouse [The cost for 1 Logitech Optical Mouse is RM " << Price_Mouse << " ] ? ";
cin >> Mouse;
Cost_Mouse = (Mouse)*(Price_Mouse);
cout << "\n\n";
cout << "So, the total cost for this week is " << ( (Cost_Headphone) + (Cost_Mouse) + (Cost_USB) ) << "." << "\n";
cout << "And your remainder is RM" << ( (Capital) - ( (Cost_Headphone) + (Cost_Mouse) + (Cost_USB) ) ) << "." << "\n\n";
int Yes_or_No, Number_of_workers, Wage, Total_wage;
Wage = 120.00;
cout << "Do you hire worker(s) (ENTER 0 for NO and 1 for YES)? \n";
cin >> Yes_or_No;
if ( Yes_or_No ==1) {
cout << "How many (Wage for worker(s) is RM 120.00 per week)? ";
cin >> Number_of_workers;
Total_wage = (Number_of_workers)*(Wage);
}
cout << "\n\n";
cout << "So, shall we start our operations for this week? (ENTER 1 to START and 0 to CHECK your settings)";
}
That is where I am currently now in progress...