HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Software / Tools > Programming, Coding, (Web)Design


Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people.

Reply
 
Thread Tools
Old Aug 28, 2003, 08:21 PM   #1
Car Audio Guy
 
Join Date: Jul 2003
Location: Atlanta, Ga
Posts: 499
Rep Power: 0
Davidgt is on a distinguished road

Look what I made in C

/* Program will display a menu for a deli and allow the user to choose how many pounds of meat they want */
#include <stdio.h>
#include <process.h>
#include <conio.h>
int main()
{
char sel;
double suma, sumb, sumc, lbs;
while (1)
{
printf ("Welcome to David`s deli. Please make a choice from the selction below\n\n\n");
printf ( "A. Ham $1.99 lb\n" );
printf ( "B. Turkey $2.99 lb\n" );
printf ( "C. Roast Beef 3.99 lb\n" );
printf ( "X. Exit\n\n" );
printf ( "Enter the letter of the type of meat you would like\n");
printf ( "Enter X when you want to exit\n\n\n" );
scanf ( "%s", &sel );
system ( "cls" );


if ( sel == 'a' || sel == 'A' || sel == 'b' || sel == 'B' || sel == 'c' || sel == 'C' )
{
printf ( "Enter the number of pounds you would like\n" );
scanf ( "%lf", &lbs );
system ( "cls" );
}
switch ( sel )
{


case 'A' :case 'a':
suma = lbs * 1.99;
printf ( "The total is %.2lf\n", suma );
break;

case 'B' :case 'b':
sumb = lbs * 2.99;
printf ( "The total is %.2lf\n", sumb );
break;

case 'C' :case 'c':
sumc = lbs * 3.99;
printf ( "The total is %.2lf\n", sumc );
break;

case 'X' : case 'x':

printf("Have a great day! Please come agian");
_getche ();
system ( "cls" );
break;

default:
system ( "cls" );
printf("You have made an invaild selection. Please choose your selection agian");


}
_getche ();
system ( "cls" );

}


return 0;


}

neat eh?
__________________
Sales/Support Manager Taraautosound.com

wonderful sig by tastyweat
Davidgt is offline   Reply With Quote


Old Aug 28, 2003, 08:26 PM Threadstarter Thread Starter   #2
Car Audio Guy
 
Join Date: Jul 2003
Location: Atlanta, Ga
Posts: 499
Rep Power: 0
Davidgt is on a distinguished road

some more I made

/* Program will determine each employees gross pay */
#include <stdio.h>

int main()
{
int hw, ov;
float hp, gp, ovp, ovt, sal;

printf ( "Enter number of hours worked (-1 to end)\n" );
scanf ( "%d", &hw );
while ( hw > -1 ){
printf ( "Enter hourly rate\n" );
scanf ( "%f", &hp );
gp = hp * hw;
if (hw > 40){
ov = hw - 40;
ovp = hp / 2;
ovt = ovp * ov;
sal = ovp + gp;
printf ( "Salary is %.2f\n", sal );
}
if ( hw <= 40 )
printf ( "Salary is %.2f\n", gp );
printf ( "Enter number of hours worked\n" );
scanf ( "%d", &hw );
}
return 0;
}


//Input three different integers

#include <stdio.h>

int main ()

{

int integer1, integer2, integer3, sum , average, product, largest, smallest;

printf ( "Input three different integers" );
scanf ( "%d%d%d", &integer1 , &integer2 , &integer3 );
sum = integer1 + integer2 + integer3;
printf ( "Sum is %d\n", sum );
average = sum /3;
printf ( "average is %d\n", average );
product = integer1 *integer2 *integer3;
printf ( "product is %d\n", product );
smallest = integer1;

if (integer1> integer2);
smallest = integer2;

if (integer2 > integer3);
smallest = integer3;

if (integer3 > integer1);
smallest= integer1;
printf ( "smallest is %d\n" , smallest);

largest = integer2;

if (integer2 < integer3);
largest = integer3;

if (integer3 < integer1);
largest = integer1;

if (integer1 < integer2);
largest= integer2;
printf ( "largest is %d\n" , largest);

return 0;

}





/* determine if somone is old enough to vote */

#include <stdio.h>

int main ()
{
int age;
char reg;

printf ( " Enter your age \n" );
scanf ("%d",&age ) ;

if (age >= 18 )
{
printf ("Are you registered to vote? Enter y for YES and n for NO\n ");
scanf ("%s", &reg);

if (reg == 'y' || reg == 'Y')
printf ( "You can vote \n");

if ( reg == 'n' || reg == 'N' )
printf ("But You need to register before voting \n");
}
if( age < 18 )
printf ("You are to young to vote!\n" );

return 0;
}



I am getting pretty good in C About to start advanced C in college

feel free to compile these and play
__________________
Sales/Support Manager Taraautosound.com

wonderful sig by tastyweat
Davidgt is offline   Reply With Quote
Old Aug 28, 2003, 09:21 PM   #3
Yarr... I be blind!
 
Jeff's Avatar
 
Join Date: May 2002
Location: Calgary, Canada
Posts: 3,191
Rep Power: 80
Jeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud ofJeff has much to be proud of

Thread moved to more appropriate forum.
__________________
Jeff is offline   Reply With Quote
Reply

Thread Tools