Like Tree1Likes
  • 1 Post By Salem

Challenge ..in cprogram

This is a discussion on Challenge ..in cprogram within the C Programming forums, part of the General Programming Boards category; Menu [A] Age [N] number [T] Temperature [R] Remarks [p] Payroll [e] Exit Enter your choice: [A] Age enter an ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    13

    Challenge ..in cprogram

    Menu
    [A] Age
    [N] number
    [T] Temperature
    [R] Remarks
    [p] Payroll
    [e] Exit
    Enter your choice:


    [A] Age
    enter an age:
    -your qualified
    -your not qualified
    would u try again(back to menu)



    [n]numbers
    [1] postive/negative
    [2] even /odd
    enter choice;
    [1] positve / negative
    enter number:
    -number is postive
    -number is negative
    [2] odd / even
    enter number;
    - number is odd
    -number is even
    would u try again(back to menu)



    [t] temperature
    [1] farenheit to celsius
    [2] celsius to farenheit
    enter choice:

    [1] farenheit to celsius
    enter farenheit
    - result
    [2] celsius to farenheit
    enter celsius
    -result
    would u try again(back to menu)


    [p] Payroll
    [1] higher position
    [2] middle position
    [3] lower position
    name:
    working hours:
    hourly rate:
    overtime: (overtime = working hours- 40hours)
    undertime:
    position:
    gross income:
    tax(12%)
    sss(8%)
    Philhealth(1.25%)
    total deductions: (total=tax+grossincome+sss+philhealth)
    net income: (=gross income - deduction)
    goto menu......


    ...only this information will be given....
    ...thats the challenge .....
    ..good luck...

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    Nice homework, how about you give it a shot first.
    Crossfire likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    hahaha...

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,307
    You laugh, but Salem is spot on. This site has a homework policy, at this link.

    The short summary of that policy .... Do your own homework.

    The sort of "challenge" you gave is one of many approaches that lazy students use in an attempt to get people here to do homework.

    If you make an honest effort at doing your homework (yes, people here are experienced enough to tell the difference) you will find people more helpful.
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    oh?! im sorry....
    its my homework its my exam... last week that i didnt finish on sched..... and i just want to know what is the rights program.!!!
    im so curios...

    im sorry to all!!

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    The "right" answer is a program which behaves as you have documented in your original post.

    The answer you come up with will be different from the answer I come up with, but neither would be more "right" so long as both behaved as desired.

    You can only get so far by just looking at other peoples code. To make your own, you have to practice (and practice, and practice).
    It's all very well understanding that code does what it does, but you won't be able to replicate the thought processes which go into making code unless you actually make code yourself.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,389
    You also might want to read the article in the link at the bottom of Salem's post "If at first you don't succeed, try writing your phone number on the exam paper", and then reconsider how much effort you have put into the subject.
    Fact - Beethoven wrote his first symphony in C

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    Code:
    #include <stdio.h>
    #include <conio.h>
    int main ()
    
    
    {
    
    
    #define p printf
    #define s scanf
    
    
    char choice,answer,ch1,ch2,ch3,ch4,ch5,tfname[20],tlname[20],fname[20],lname[20];
    char section,subject,ch6,ch7,ch8,ch9,ch10;
    char choice3,higher,middle,lower;
    float position,workinghours,hourlyrate,overtimepay,grossincome,netincome;
    float tax,sss,philhealth,td;
    float undertime,overtime;
    float cel,fahr,temp1,temp2;
    int age,choice2,celcius,fahrenheit,positive,odd;
    int no=0;
    
    
    
    
    
    
    clrscr();
    do
    {
    p("Final Exam in IT 121\n");
    p("Prepared By:\n");
    p("Name: Michael Lano\n");
    p("Name: Lenelyn Tud\n");
    
    
    p("==========================================\n");
    
    
    p("[A] Age\n");
    p("[N] Number\n");
    p("[T] Temperature\n");
    p("[R] Remarks\n");
    p("[P] Payroll\n");
    p("[E] Exit\n");
    p("\nEnter Your Choice:");
    s("%s",&choice);
    
    
    ch1='a';
    ch2='t';
    ch3='n';
    ch4='p';
    ch5='r';
    ch6='A';
    ch7='T';
    ch8='N';
    ch9='P';
    ch10='R';
    
    
    clrscr();
    
    
    if(choice==ch1 || choice==ch6)
    {
       p("Age\n");
    
    
       p("Please Enter Your Age:");
       s("%d",&age);
    
    
    	if(age>=18)
    	{
    	p("You Are Qualified");
    	}
    	else
    	{
    	p("You Are Not Qualified");
    	}
    }
    
    
    
    
    if(choice==ch2  || choice==ch7 )
    {
    	p(" Temperature\n");
    
    
    	p("[1] Fahrenheit to Celcius\n");
    	p("[2] Celcius to Fahrenheit\n");
    	p("Enter Your Choice:");
    	s("%d",&choice2);
    
    
    	fahrenheit=1;
    
    
    	celcius=2;
    
    
    	if(choice2==fahrenheit)
    	{
    	p(" Fahrenheit to Celcius\n\n");
    	p("Enter Temperature in Fahrenheit:");
    	s("%f",&temp1);
    	cel=((temp1-32)*5)/9;
    	p("\n\n");
    	p("Equivalent in Celcius:%.2f\n",cel);
    	}
    	else if(choice2==celcius)
    	{
    	p(" Celcius To Fahrenheit\n");
    	p("Enter Temperature in Celcius:");
    	s("%f",&temp2);
    	fahr=((temp2*9)/5)+32;
    	p("Equivalent in Fahrenheit:%.2f\n",fahr);
    	}
    }
    
    
    if(choice==ch3 || choice==ch8)
    {
    	p("Numbers\n");
    	p("[1] Positive & Negative\n");
    	p("[2] Odd & Even\n");
    	p("Enter Your Choice:");
    	s("%d", &choice2);
    
    
    	positive=1;
    	odd=2;
    
    
      if(choice2==positive)
      {
    	p("Positive & Negative\n");
    	p("Enter Number:");
    	s("%d", &no);
    	if(no>0)
    	{
    	p("Positive");
    	}
    	else if(no<0)
    	{
    	p("Negative");
    	}
    	else
    	{
    	p("Zero");
    	}
      }
    
    
      else if(choice2==odd)
      {
    	p("ODD & EVEN\n");
    	p("Enter Number:");
    	s("%d",&no);
    
    
    	if ((no%2)==0)
    	{
    	p("Even");
    	}
    	else
    	{
    	p("ODD");
    	}
      }
    }
    
    
    if(choice==ch4 || choice==ch9)
    {
    
    
    	p("Positio\n");
    	p("[1]higher\n");
    	p("[2]Middle\n");
    	p("[3]lower\n");
    	p("Enter Your Choice:");
    	s("%d", &choice3);
    higher=1;
    middle=2;
    lower=3;
    
    
      if(choice3==higher)
      {
    	p("Enter Your Name:");
    	s("%s %s",&fname,lname);
    	p("Enter Your Working Hours:");
    	s("%f", &workinghours);
    	p("Enter Hourly Rate:");
    	s("%f",&hourlyrate);
    	
    
    
    	if(workinghours>40)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Higher\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	overtime=workinghours-40;
    	p("Overtime :%.0f\n",overtime);
    	p("Undertime : --zero--\n");
    	overtimepay=(workinghours-40)*(hourlyrate);
    	p("Overtime Pay:%.2f\n",overtimepay);
    	grossincome=(workinghours*hourlyrate)+overtimepay;
    	p("Gross Income:%.2f\n\n",grossincome);
    	tax=grossincome*.12;
    	p("Tax:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("Philhealth:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	p("Total Deduction:%.2f",td);
    	netincome=grossincome-td;
    	p("Net Income:%.2f\n\n",netincome);
    	}
    
    
    
    
    	else if (workinghours<=8)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Higher\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime :--zero--\n",overtime);
    	undertime=workinghours-8;
    	p("Undertime : %.0f\n",undertime);
    	p("Overtime Pay:--zero--\n",overtimepay);
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
    
    
    	else
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Higher\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime:--zero--\n");
    	p("Undertime ::--zero--\n");
    	p("Overtime Pay:--zero--\n");
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
    
    
      }
    
    
      if(choice3==middle)
      {
    	p("Enter Your Name:");
    	s("%s %s",&fname,lname);
    	p("Enter Your Working Hours:");
    	s("%f",&workinghours);
    	p("Enter Hourly Rate:");
    	s("%f",&hourlyrate);
    	
    
    
    	if(workinghours>40)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	overtime=workinghours-40;
    	p("Overtime :%.0f\n",overtime);
    	p("Undertime : --zero--\n");
    	overtimepay=(workinghours-40)*(hourlyrate);
    	p("Overtime Pay:%.2f\n",overtimepay);
    	grossincome=(workinghours*hourlyrate)+overtimepay;
    	p("Gross Income:%.2f\n\n",grossincome);
    	tax=grossincome*.12;
    	p("Tax:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("Philhealth:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	p("Total Deduction:%.2f",td);
    	netincome=grossincome-td;
    	p("Net Income:%.2f\n\n",netincome);
    	}
    
    
    
    
    	else if (workinghours<=8)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime :--zero--\n",overtime);
    	undertime=workinghours-8;
    	p("Undertime : %.0f\n",undertime);
    	p("Overtime Pay:--zero--\n",overtimepay);
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
    
    
    	else
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime:--zero--\n");
    	p("Undertime ::--zero--\n");
    	p("Overtime Pay:--zero--\n");
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
    
    
    
    
      }
      if(choice3==lower)
      {
    	p("Enter Your Name:");
    	s("%s %s",&fname,lname);
    	p("Enter Your Working Hours:");
    	s("%f",&workinghours);
    	p("Enter Hourly Rate:");
    	s("%f",&hourlyrate);
    	
    
    
    	if(workinghours>40)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	overtime=workinghours-40;
    	p("Overtime :%.0f\n",overtime);
    	p("Undertime : --zero--\n");
    	overtimepay=(workinghours-40)*(hourlyrate);
    	p("Overtime Pay:%.2f\n",overtimepay);
    	grossincome=(workinghours*hourlyrate)+overtimepay;
    	p("Gross Income:%.2f\n\n",grossincome);
    	tax=grossincome*.12;
    	p("Tax:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("Philhealth:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	p("Total Deduction:%.2f",td);
    	netincome=grossincome-td;
    	p("Net Income:%.2f\n\n",netincome);
    	}
    
    
    
    
    	else if (workinghours<=8)
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime :--zero--\n",overtime);
    	undertime=workinghours-8;
    	p("Undertime : %.0f\n",undertime);
    	p("Overtime Pay:--zero--\n",overtimepay);
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
    
    
    	else
    	{
    	p("\n");
    	p("Name:%s %s\n",fname,lname);
    	p("Position:Middle\n");
    	p("Hourly Rate: %.0f\n",hourlyrate);
    	p("Overtime:--zero--\n");
    	p("Undertime ::--zero--\n");
    	p("Overtime Pay:--zero--\n");
    	grossincome=workinghours*hourlyrate;
    	tax=grossincome*.12;
    	p("TAX:%.2f\n\n",tax);
    	sss=grossincome*.08;
    	p("SSS:%.2f\n\n",sss);
    	philhealth=grossincome*.0125;
    	p("PHILHEALTH:%.2f\n\n",philhealth);
    	td=tax+sss+philhealth;
    	netincome=grossincome-td;
    	p("Total Deduction:%.2f\n\n",td);
    	p("Net Income:%.2f\n\n",netincome);
            }
      }
    
    
    if(choice==ch5 || choice==ch10)
    {
      p("REMARKS\n");
      p("Enter Your Name:");
      s("%s %s\n",&fname,lname);
      p("Enter Your Section:");
      s("%s %s\n",&section);
      p("Enter Your Subject:");
      s("%s",&subject);
      p("Enter Your Teacher:");
      s("%s %s\n", &tfname,tlname);
      p("Enter Grade:");
      s("%f",&subject);
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    clrscr();
    p("------------------------------------\n");
    }
    else
    {
    p("1");
    }
    }
    else
    {
    p("2\n");
    }
    p("\nWould you like to try again?[Y/N]:");
    answer=getch();
    clrscr();
    }
    while(answer=='y' || answer=='Y');
    exit();
    getch();
    }
    i did not finish on part of remarks
    and i dont know how to an exit code





    i just look it to my drafts...

  9. #9
    Registered User
    Join Date
    Dec 2012
    Posts
    289
    i am amazed that this is a final exam, with the names for the grade being two
    people, and between both of you, the program looks like that? as well as being lost how to exit?

    not to mention the school still uses conio.h


    actually after looking at it, the program has two names on it, which dont look like your name....

    me thinks you are trying to cheat already....

    so i must say, i am not going to be part of this one. to many things that dont seem right
    Last edited by Crossfire; 02-11-2013 at 09:53 AM.

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I see line 462 needs either another string to put data into, or one less %s in the format specification:
    Code:
     s("%s %s\n",&section);
    And "section" is a char, so it can't hold a string. Did you mean for this to have " %c", instead?

    What errors or warnings are you receiving?

    Can you #define s to be scanf, and then use sss in a variable name? I've no idea, if that will work OK, or not.
    Last edited by Adak; 02-11-2013 at 10:03 AM.

  11. #11
    Registered User loserone+_+'s Avatar
    Join Date
    Dec 2012
    Location
    Indonesia
    Posts
    112
    Quote Originally Posted by Crossfire
    not to mention the school still uses conio.h
    sorry for interupting but was that conio.h meaning in c proggraming language?
    my college use it to, and i didnt understand that
    sorry if my questions arent fit on this thread but it bothers me when Cross file mention conio.h used for schools
    thankss for respons,

  12. #12
    Registered User
    Join Date
    Jun 2005
    Posts
    6,307
    Quote Originally Posted by loserone+_+ View Post
    sorry for interupting but was that conio.h meaning in c proggraming language?
    my college use it to, and i didnt understand that
    sorry if my questions arent fit on this thread but it bothers me when Cross file mention conio.h used for schools
    <conio.h> and the functions declared in it are not part of standard C. They are extensions specific to a couple of compilers and operating systems. Those compilers and host operating systems became obsolete at least ten years ago.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cprogram for grades.....pls help
    By Kira Patricio in forum C Programming
    Replies: 14
    Last Post: 02-10-2013, 02:31 AM
  2. Cprogram Input/output parameter HELP
    By 123456tacos in forum C Programming
    Replies: 5
    Last Post: 03-11-2011, 09:59 PM
  3. Homework HELP! CProgram Electric Company
    By 123456tacos in forum C Programming
    Replies: 20
    Last Post: 03-04-2011, 09:33 PM
  4. Cprogram/Excel/Bargraph
    By friend in forum C Programming
    Replies: 3
    Last Post: 09-15-2003, 04:44 PM
  5. Challenge just for fun
    By Bob123 in forum C Programming
    Replies: 2
    Last Post: 03-18-2002, 11:07 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21