Thread: Displaying a table

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    2

    Displaying a table

    This assignment asked me to calculate the salary, and I have done the most of it.

    However, the last part of the assignment asked me to display a table of the salary of each day, the total pay at the end of the period. I have worked on this for hours, and have no idea why it doesn't show a correct table. And my text book doesn't say a damn thing about displaying the table.

    The program only shows the last day.

    I am using Visual C++, thanks a lot!

    Code:
    #include <iostream.h>
    #include <math.h>
    #include <iomanip.h>
    
    void main(void)
    {
    	float days;
    	long double total = 0;
    	
    	cout << "Please input the number of day for calculation, do NOT enter a value which less than '1'!\n";
    	cin >> days;
    	cout << "\n";
    	
    	while (days < 1)
    	{
    		cout << "Warning! You little dork please READ the instruction!\n\n";
    		cout << "Now, I will give you another chance...enter the number of day again!\n" << endl;
    		cin >> days;
    		cout << "\n\n";
    	}
    	
    	float penny;
    	long double pay;
    	cout << "Please input the pay for the first day (in penny)\n";
    	cin >> penny;
    	pay = penny * 0.01;
    	cout << endl;
    	
    	cout << setw(6) << "Day";
    	cout << setw(25) << "Pay for today";
    	cout << setw(35) << "Total $$$$ you have made" << endl;
    	cout << "---------------------------------------------------------------------\n";
    	
    	if (days >= 1)
    	{
    		for (int count= 1 ; count <= days; count++);
    		{
    			
    			long double payperday;
    			payperday = pay * (pow (2 , (count - 2)));
    			total += payperday;
    			
    			cout << setw(5)  << days;
    			cout << setw(20) << payperday;
    			cout << setw(30) << total << "\n\n\n"<< endl;
    			
    			cout << setprecision(1) << setiosflags(ios::dec | ios::fixed) <<"The total pay is $" << total << "\n\n";
    		
    		}
    	}
    	
    	
    }
    Last edited by hkguy; 03-29-2004 at 01:00 AM. Reason: removing attachment

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying a table of arbitrary values?
    By cbmurdock in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:59 AM
  2. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  3. extra word printing
    By kashifk in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2003, 04:03 PM
  4. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM
  5. displaying the contents of an html file in a table
    By confuted in forum Tech Board
    Replies: 3
    Last Post: 08-02-2003, 07:50 PM