← Back to Kurakani

Help on c program

Original Post

Is there any one who can help on C programming? This my first program class and i am having really hard time understanding it. would you guys PLEASE help me out? here is the question. A company pays its employees as managers (who receive a fised weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hrs they work and time and half for overtime hrs), commision workers(who receive a $250 olus 5.7% of their gross weekly sales), or pieceworkers(who receive a fixed amount of one type of item). write a program to compute the weekely pay for each employee. you do not know the number of employees in advance. Each type of employee has its own pay code: Managers have paycode 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a "SWITCH" to compute each employee's pay based on tha employee;s paycode. within the "SWITCH", prompt the user(i.e the payroll clerk) to enter the appropriate facts your program needs to calculate each employee's pay based on that employee's paycode. (your program must use loop)

unit
Jun 20, 2006 7:58 PM · 26,045 views
31 Replies · Showing 21 - 31
Page 2 of 2
flip_flop Jun 20, 2006 11:21 PM
Though You are not CS major thapap, you still need to learn a lot about writing codes, don't ya? Circuits and programming go along very well.
thapap Jun 20, 2006 11:25 PM
flippu, u r vry smart kya.. and i am intimidated by ur grace. sanchi bhaneko. ani 2 answer ur question. presently, EE need to have hands on on programming including databases (O: and for ans 2 other question.. pls look @ ur email. (O:
loote Jun 20, 2006 11:29 PM
sure Im1 u can do that in MATLAB.. Matlab has C extension to it.. thapap, u r going to kill imi...hehe. creating a browser based form with C? why u need to take that pain when u have application oriented VB to deal with? CT baata AL jaana "via europe" ticket katya jasto kura bho ni ;) Loote
ImI Jun 20, 2006 11:30 PM
oh i need easy way out, i want the Access to do that for me.:) And i am not EE from 1990s i am from 2000s.You are making me sound like 30+ person man . com'on .I was just fooling around with loote . loote yep AI is the class i learnt Lisp and i hate it.I have no use for that crap.Matlab is fun.Writing C functions to connect with Access???I would probablly go with VB that is much easier. And MIT hahaha Some what MIT??its a secret:) Any access experts???
thapap Jun 20, 2006 11:33 PM
loote, k garne ta. "OLD IS GOLD" FORTRAN bata C ma janu ta kati tension hunchha.. tesh mathi VB re bho aaba .. tesaile.. MATLAB use garne lai MATLAB ko C extension use garera.. form banaune bhaneko ni.... (O: Actually, using JAVA its very easy by creating an applet. 1 simple program done (O:.
loote Jun 20, 2006 11:40 PM
ok i m nearly maxing out with both my ids. so dont mind me if u dont see my reply again. With Matlab and C's extension, it will take at least 100 lines of codes to create a simple form with a text box and a button (i m not sure how IMI's forms are demanding for the outlook) then connectivity with access from C...man you are asking for more codes here. VB is the easiest platform for RAD (Rapid application development). you can create a form right away in minutes and plus the ODBC is all inbuilt in the IDE itself. so i am telling him to go for this. With Java, sure. but again u need to have a hands on experience with basic java, a little bit of OOP knowledge so that is not gonna help much. If IMI knows Java then fine. Loote
thapap Jun 20, 2006 11:52 PM
loote, using 2 ids.. dyamn... what' sthe other one dawg (O:
loote Jun 20, 2006 11:52 PM
and one more thing. I wont say nything abt fortran coz its pretty outdated now. but lisp is way way powerful. i am not 100% sure if it actually supports browser feature but when it comes to Artificial intelligence Programming I prefer it to C. so its not an OLDY by any means. talking abt oildies, no one uses java applet these days for web programming, (it used to be in the 90's :P). people go for servlet and JSP these days coz its more secure, latency is less, and more applicable for distributed environment. If you know STRUTS in java then you prolly know what i m talking abt. Loote. P.S,. I m not a CS major either I hope i have not maxed out. Finger crossed
flip_flop Jun 20, 2006 11:55 PM
thapap I now need to use my Nancy Drew inspired brain. You know what I mean don't ya?:@
thapap Jun 20, 2006 11:57 PM
flippu, u need 2 go read ur email and respond kya.. (O: ... that's what nancy drew wud do
JavaBeans Jun 23, 2006 6:24 PM
Ah...programming is such an art... You can easily convert this Java code into C if you wish; I'm just not sure why your lecturer is wanting you to do this in C in the first place. C is good for anything 'networking'; for high level stuff like this well...you're looking at a high level language... package com.sajha.hr.payroll; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Hashtable; /** * @author JavaBeans * */ public class CalcPay { private static BufferedReader keyboard; public static void main( String args[] ) throws IOException { keyboard = new BufferedReader( new InputStreamReader( System.in )); System.out.println("Enter Employee ID (a number):"); boolean exit=false; do { try { switch( checkValidNum() ) { case 1: calcMgr(); break; case 2: calcHourly(); break; case 3: calcCom(); break; case 4: outsrcWork(); break; default: throw new PayrlException(); } exit=true; } catch ( PayrlException pe) { System.err.println("ID's range must " + "be within 1-4. Try again."); } } while( !exit ); } static void calcMgr() throws IOException { System.out.println("Enter the Manager's " + "fixed weekly salary (a number):"); System.out.println( "The managers's gross weekly " + "income is $" + checkValidNum() + ". Bye!"); } static void calcHourly() throws IOException { System.out.println("Enter the hourly worker's " + "fixed hourly wage (a number):"); int wage = checkValidNum(); System.out.println("Now enter the number of hours " + "they've worked for the week:"); int hours = checkValidNum(); double hrlyPay=0; if( hours > 40 ) { hrlyPay=(wage*40) + ((wage*1.5)*(hours-40)); }else{ hrlyPay=wage*hours; } System.out.println( "The hourly worker's gross weekly " + "income is $" + hrlyPay + ". Bye!"); } static void calcCom() throws IOException { System.out.println("Enter the commission worker's " + "weekly sales (a number):"); System.out.println( "The commission worker's gross weekly " + "income is $" + (250+(.057*checkValidNum())) + ". Bye!"); } static void outsrcWork() throws IOException { System.out.println("Enter the item no that was " + "outsourced or contracted:"); int num=0; //simple storage of values Hashtable item = new Hashtable(); item.put("1", "1000"); item.put("2", "2000"); item.put("3", "3000"); item.put("4", "4000"); //etc.. boolean exit=false; do{ try { num = checkValidNum(); if( num>4 ) { throw new PayrlException(); } else { exit=true; } } catch( PayrlException pe ) { System.err.println("Item range must " + "be within 1-4. Try again."); } } while( !exit ); System.out.println( "The contractor's gross weekly " + "income is $" + item.get(String.valueOf( num )) + ". Bye!"); } static int checkValidNum() throws IOException { int num=-1; boolean exit=false; do { try { num= Integer.parseInt( keyboard.readLine()); exit=true; } catch( NumberFormatException nfe ) { System.err.println("I said a number! Try again: "); } }while(!exit); return num; } } class PayrlException extends Exception { public PayrlException() { super(); } } Cheers!
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant