Cheating Network
 
 

Go Back   Cheating Network > General Computing > Programming
Reload this Page HW help in C programming



Programming

This is a discussion about HW help in C programming within the Programming section, where you will Anything related to programming or scripting should go here.



Reply
 
LinkBack Thread Tools Display Modes
Old 08-31-2008, 03:29 PM   #1 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default HW help in C programming

Write a program that calculates mileage reimbursement for a salesperson at a rate of $.35 per mile. Your program should interact with a user in this manner:
MILEAGE REIMBURSEMENT CALCULATOR
Enter beginning odometer reading=> 13505.2
Enter ending odometer reading=>13810.6
You traveled 305.4 miles. At $.35 per mile, your reimbursement is $106.89.

I need help with writing a program for this problem. I know its a pretty simple problem but i'm just starting out so if someone could write this and send me the code it would help me out a lot on getting started with the rest of my assignment. Remember it has to be wrote in C.
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:33 PM   #2 (permalink)
Senior Member
 
Join Date: Jun 2008
Posts: 382
Reputation: 6
Mooey is an unknown quantity at this point
Default

I'm not going to write it for you, but if you tell me exactly what you need help with, I'll gladly help you out.
Mooey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:33 PM   #3 (permalink)
Senior Member
 
christafa.milla's Avatar
 
Join Date: Jun 2008
Posts: 546
Reputation: 54
christafa.milla will become famous soon enough
Default

Don't really think anyone is going to write this for you with -17 rep and your name, and the fact you aren't offering a exchange prize for the work that is being done.
__________________
Talk show host: Have you ever stolen anything?
Connie (Asian): [quickly] YES!!!
Maury: Connie! Wait you gotta build the suspense, that is how Fox turns 5 minutes of material into an hour long program.
-MADtv
christafa.milla is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:38 PM   #4 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default

#include <stdio.h>
#define REIMBURSE_PER_MILE 0.35
int
main(void)
{
double begmiles;
double endmiles,
reimbursement;

/* Get the beginning amount of miles*/
printf("Enter beginning odometer reading=>");
scanf("%lf", &begmiles);

/*Get the ending ammount of miles*/
printf("Enter ending odometer reading=>");
scanf("%lf", &endmiles);

/*Tell How many miles traveled*/
scanf("endmiles+-begmiles");
printf("You traveled (endmiles+-begmiles) miles.");

return(0);
}



That is what i have written so far, what happens is it asks me for beginning miles and i enter it then it asks for ending miles and i enter it then it quits. I think i'm having trouble with naming the variables.
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:39 PM   #5 (permalink)
Senior Member
 
Guo0's Avatar
 
Join Date: Dec 2007
Posts: 660
Reputation: 18
Guo0 is on a distinguished road
Default

This is on C++

int main ()
{
double a, b,c;
cout <<"MILEAGE REIMBURSEMENT CALCULATOR"<<endl;
cout <<"Enter beginning odometer reading"
cin >>a
cout <<endl<<"Enter ending odometer reading";
cin>>b

c=b-c;

cout <<"You traveled<< c << "miles";
cout <<"You traveled<< c <<"miles." << " At $.35 per mile, your reimbursement is << c*.35;

return 0;
}
__________________
Guo0 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:42 PM   #6 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default

Thanks for the C++ but i have never used that and the class is just in C so I don't think that would be accepted. If you could write in C that would be awesome!
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:44 PM   #7 (permalink)
Senior Member
 
Join Date: May 2008
Posts: 514
Reputation: 12
dont.blink. is on a distinguished road
Default

you're using printf wrong
dont.blink. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:45 PM   #8 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default

Quote:
Originally Posted by dont.blink. View Post
you're using printf wrong
what did i do wrong with it?
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:47 PM   #9 (permalink)
Senior Member
 
Join Date: May 2008
Posts: 514
Reputation: 12
dont.blink. is on a distinguished road
Default

if you want to print a difference you do this:

beg = 10;
end = 20;

printf("the difference is %d", (end - beg));

btw d is integer you'd have to use lf since you used double
dont.blink. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:51 PM   #10 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default

Ok thanks! but the program still quits right after i type in the ending miles
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:53 PM   #11 (permalink)
Senior Member
 
Join Date: May 2008
Posts: 514
Reputation: 12
dont.blink. is on a distinguished road
Default

that's because it runs out of lines of code all you have to do is

1. set up variable for the difference in miles
2. print the difference
3. multiply the difference by the reimbursment mount and store it
4. print that variable

and you're done
dont.blink. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:55 PM   #12 (permalink)
Senior Member
 
dopex's Avatar
 
Join Date: Dec 2007
Posts: 914
Reputation: 45
dopex is on a distinguished road
Send a message via ICQ to dopex Send a message via AIM to dopex Send a message via MSN to dopex Send a message via Yahoo to dopex Send a message via Skype™ to dopex
Default

i wish i had a c class :p.
__________________

<assault14> why are u being prejitist and calling us gays

Dan offered $1.50 to do offer with fraud CC details but said it was (his own).
dopex is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-31-2008, 03:59 PM   #13 (permalink)
Senior Member
 
Join Date: Mar 2008
Posts: 103
Reputation: -24
bigfatturd can only hope to improve
Default

ok thanks, i did that and it doesn't pause the program when it the next step comes up and i can't remember how to make it pause and wait for a button to be pressed, is it pause char?

#include <stdio.h>
#define REIMBURSE_PER_MILE 0.35
int
main(void)
{
double begmiles;
double endmiles,
reimbursement;

/* Get the beginning amount of miles*/
printf("Enter beginning odometer reading=>");
scanf("%lf", &begmiles);

/*Get the ending ammount of miles*/
printf("Enter ending odometer reading=>");
scanf("%lf", &endmiles);

/*Tell How many miles traveled*/
scanf("endmiles-begmiles");
printf("the difference is %d", (endmiles - begmiles));

/*Multiply the difference by the rate*/
printf("%d*REIMBURSE_PER_MILE");

return(0);
}

That is what i have and i'm stuck i know it is way wrong but i have no idea what to do.

Last edited by bigfatturd; 08-31-2008 at 04:14 PM.
bigfatturd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
hw, programming


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stuck on ahk need some help for some simple programming shemer77 Bot Makers 5 08-11-2008 06:29 PM
Web Programming question Seatbelt99 Other / Unlisted Networks 11 04-04-2008 07:03 AM
Programming Session. impuLsivE Announcements 5 01-27-2008 02:53 PM
Who is decent with programming? snowboardbum Chit Chat 3 01-11-2008 04:35 PM
Anyone have experience programming motor controlers? ahage16 Chit Chat 1 12-23-2007 03:55 PM


Powered by vBulletin
Copyright © 2000-2008 Jelsoft Enterprises Limited.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.