473,698 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change of program

SK
Hi
I am trying a simpler version of a program I was trying to write. The
idea is to have someone enter the information and then at the end of
the program display all of the info. in a table. I have a feeling the
errors I am making are probably stupid but I would appreciate any
imput.

//Specs to be added later

//C Libraries
#include <stdio.h>
#include <math.h>
#include <string.h>

//Global Variable Declaratives
FILE*inp;

char Fname[10];
char Lname[10];
char department[20];
char again;
char FULLNAME[30];

int count_EMP;
int number_EMP;

float wage;
float OTwage;
float hours;
float RegHr;
float RegHrPay;
float OTHrPay;
float OTHr;
float GrossPay;

//Function Prototypes
void GetInfo(void);
void Process(void);
void Report(void);

int main(void)
{

GetInfo();

system("pause") ;

return 0;
}
void GetInfo(void)
{
do{
printf("\nPleas e enter the first and last name of the
employee:");
scanf("%s %s", &Fname, &Lname);

printf("\nPleas e enter the hourly wage for the employee: ");
scanf("%f", &wage);

printf("\nPleas e enter the number of hours worked this week:
");
scanf("%f", &hours);
printf("\nDo you want to enter another employee into the
payroll for"
"week?");
scanf("%s", &again);
}while(again == 'Y' || again == 'y');


if (RegHr > 40)
{
OTHr = hours - 40;
OTHrPay = 1.5 * OTHr * wage;
RegHrPay = 40.0 * wage;
}

else
{
RegHrPay = hours * wage;
OTHrPay = 0.0;

}

GrossPay = RegHrPay + OTHrPay;

if(count_EMP>=1 );

for (count_EMP = 0;
count_EMP < number_EMP;
count_EMP++);

strcpy(FULLNAME , Fname);
strcat(FULLNAME , Lname);

scanf("%s%f%f%f \n\n", &FULLNAME, &RegHr, &OTHr, &GrossPay);
if(again != 'Y' && again !='y');
printf("End of processing\n\n\ n");

printf("\n\nMou ntain Pacific Corporation\n") ;
printf("Departm ent Salary Program\n\n");
printf("Departm ent: %s\n\n", department);

printf("Employe e Reg Hrs "
"Overtime Hrs Gross\n");
printf("-----------------------------------------"
"-------------------------\n\n");

printf("%-20s%11.2f%11.2f %11.2f", FULLNAME, RegHr, OTHr,
GrossPay);

}

Nov 15 '05 #1
1 1343
On 13 Nov 2005 12:31:38 -0800, "SK" <ba******@aol.c om> wrote:
Hi
I am trying a simpler version of a program I was trying to write. The
idea is to have someone enter the information and then at the end of
the program display all of the info. in a table. I have a feeling the
errors I am making are probably stupid but I would appreciate any
imput.

//Specs to be added later

//C Libraries
#include <stdio.h>
#include <math.h>
#include <string.h>

//Global Variable Declaratives
FILE*inp;

char Fname[10];
char Lname[10];
char department[20];
char again;
char FULLNAME[30];

int count_EMP;
int number_EMP;

float wage;
float OTwage;
float hours;
float RegHr;
float RegHrPay;
float OTHrPay;
float OTHr;
float GrossPay;

//Function Prototypes
void GetInfo(void);
void Process(void);
void Report(void);

int main(void)
{

GetInfo();

system("pause") ;

return 0;
}
void GetInfo(void)
{
do{
printf("\nPleas e enter the first and last name of the
employee:");
scanf("%s %s", &Fname, &Lname);
The %s formats require the corresponding arguments to be pointers to
char. The arguments you provide are pointers to array of char. On
most systems this difference is probably irrelevant but it pays to do
it right. Remove the &s.

printf("\nPleas e enter the hourly wage for the employee: ");
Output that does not end with a \n may not be visible when the system
waits for user input. If you want the input on the same line as the
prompt, use fflush to flush the output stream.
scanf("%f", &wage);

printf("\nPleas e enter the number of hours worked this week:
");
scanf("%f", &hours);
printf("\nDo you want to enter another employee into the
payroll for"
"week?");
scanf("%s", &again);
}while(again == 'Y' || again == 'y');
If the user answers yes, the new input will replace all the previous
input which will never be processed.


if (RegHr > 40)
{
OTHr = hours - 40;
OTHrPay = 1.5 * OTHr * wage;
RegHrPay = 40.0 * wage;
You are very inconsistent with your constants. Here you use 40 and
40.0. Not a technical problem but when you come back to the program
after several months it will be just another confusion factor.
}

else
{
RegHrPay = hours * wage;
OTHrPay = 0.0;

}

GrossPay = RegHrPay + OTHrPay;



Is there some reason for all this wasted vertical space? It only
serves to disrupt the visual flow of the program.
if(count_EMP>=1 );

for (count_EMP = 0;
count_EMP < number_EMP;
count_EMP++);
Where do any of these get incremented?

strcpy(FULLNAME , Fname);
strcat(FULLNAME , Lname);
Do you really want DoeJohn as the result?

scanf("%s%f%f%f \n\n", &FULLNAME, &RegHr, &OTHr, &GrossPay);
Did you mean printf here? If so, remove all the &s. Why would you
print here and then again below? What was your real intent?


if(again != 'Y' && again !='y');
Based on the do while above, again cannot be 'Y' or 'y'.
printf("End of processing\n\n\ n");

printf("\n\nMou ntain Pacific Corporation\n") ;
printf("Departm ent Salary Program\n\n");
printf("Departm ent: %s\n\n", department);

printf("Employe e Reg Hrs "
"Overtime Hrs Gross\n");
printf("-----------------------------------------"
"-------------------------\n\n");

printf("%-20s%11.2f%11.2f %11.2f", FULLNAME, RegHr, OTHr,
GrossPay);
You probably want a \n at the end of the format string.



}

<<Remove the del for email>>
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2645
by: yongsing | last post by:
I have a Windows 2000 Server machine that runs DB2 UDB v7 fixpak 11. I also have a Java program that uses JDBC to insert data into the database. Sometimes, the program encounters SQL0302N error ("The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use", SQLSTATE=22001) when it tries to insert a particular data into a table. On my notebook, if I run the same program with the same data (and...
2
1975
by: david | last post by:
When you right click on a file in windows, there is a property of type of file, which seems to associate this file with an application for it. For example, when you double click on a .doc file, the microsoft word application is activiated and open the file. I have the following question: When I instored my image files in my computer, the system assign the default application to files automatically so that whenever I double click any...
1
8415
by: nicksop | last post by:
How can i change of a setup project in vb .net For example how can i change the path of C:\program files\myprogram\program.exe and make it D:\program files\myprogram\program.exe
3
1968
by: Ubergeek | last post by:
I have a project (Win32 application) that I want to change to a console application. Does anyone know what to edit in which file, to implement the change?
3
2823
by: vatsa | last post by:
Hi all, we can simply change value of PS1 from command prompt . but I want to change the value of PS1 from within a c program. i tried to do that using getenv & putenv. but it is n't working... . i even wrote 1 code to print all environment variables, among them PS1 wasn't there. but when i use "set" command on command prompt, it displays PS1 too among other environment variables...
8
2667
by: bim_bom | last post by:
Hi, is there any tool to change naming convention in c++ sources? I mean something, that parses cpp and h files in my project, and it finds, what variables are there declared. I think, it should have a public "CALLBACK" function (which would be impemented by me), which would tell the program, how to rename variables and functions. It should work like that: I have sourcecode:
3
7936
by: W C Hull | last post by:
We have a request from Auditing to modify the password an a local workstation administrative account every 90 days. We are developing two programs - a VB6 GUI program that will allow the administrative support person to enter a new password into an App and have that encrypted password saved in a text file. The second part is a VB6 program that only is a command line program that will open the password text file, read the encrypted...
1
16448
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
0
2209
by: shellegreen | last post by:
Hello, I need help with some password changes that I have to do in some iPAQs. The company that I work has 3 models of iPAQ and 3 different versions of Windows Mobile (Microsoft Pocket PC 4.20.0, Win Mobile 2003 SE e Win Mobile 5.0). The devices are configured to use Dial up or Cell Phone connection (Bluetooth or infrared). Recently we developed a program that check the user password expiration date in Active Directory Server every...
3
1766
by: Alan J. Salmoni | last post by:
Hello everyone, I searched through groups to find an appropriate answer to this one but could only find these which didn't meet my program's needs: http://groups.google.com/group/comp.lang.python/browse_thread/thread/53a0bfddeedf35b2/5e4b7119afa5f8df?lnk=gst&q=monitor+change+in+mutable#5e4b7119afa5f8df,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.