# Urgent helpppp!!

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 09-16-2012
Noor
Urgent helpppp!!
Im so bad in Cprogramming and i need help in this question

iRent, a fictional car rental company, is currently having a promotion advertised as “rent 3 days and drive 1 day free”. The fine print reads that 1 day within each 4-day block is free. This means that there is no discount for a rental of 1 to 3 days, however, a 4 day rental is charged for only 3 days. For rental periods of more than 4 days the same rule applies to each 4-day block in the rental period. For example, if you rent a car for 11 days you are charged for 9 days. This is because it contains two 4-day blocks plus an extra 3 days; each of these first two 4-day blocks is counted as 3 days while there is no discount for the last 3-day block.
Write a C program that calculates the total amount that a customer should pay for renting a car from iRent. A 13% HST should be applied when calculating the total amount. Your program reads in the daily rate (in dollars) and the rental period (in days). It then prints the number of free days that the customer receives, followed by the total charge (tax inclusive) rounded to two decimal places.
Here is sample output from an execution of the program:
Enter the daily rate: 28.41<enter> Enter the rental period (in days): 10<enter>
Your total free day(s) in this rental is: 2 Your total charge including taxes is: 256.83
Note: You can assume that the user enters valid numbers. You should represent the HST tax rate using a const variable.
• 09-16-2012
Noor
Please anyone!!! i have to submit it tommmorow morning!!!
• 09-16-2012
oogabooga
Start earlier next time.
• 09-16-2012
Noor
i did start earlier and i had a friend help and im still stuck!!! my major isnt programming ..it is a course i have to take in school!
• 09-16-2012
WaltP
With the information you gave there's no help to give. So I guess the best help is start by opening an editor and typing in the code you wrote so far.
• 09-16-2012
Noor, it's essential that you first post up the code that you and your friend have written, so far -- then ask specific questions, for the best answers.

You can't just dump a detailed requirement for your assignment, and no code. That will get you nothing, here.
• 09-16-2012
The Doctor
Sorry mate, we can't do your homework for you. If you have questions about certain things, feel free to ask. The people here are really helpful, but they can't do your homework for you. It doesn't help you in the long run.

This looks like it will just require a bunch of calculations, though.

use printf to ask the appropriate questions, use scanf to store the answers into variables, and then do the appropriate mathematics, as outlined in the question, to come up with the answer.

Good luck!
• 09-18-2012
Noor
I am meant to encrypt a 4-digit combination the last and first digits should be swapped and 9 should be subtracted from the second and third digit. I don't know if this is right though could someone please guide me :)

Code:

```#include <stdio.h> int main(void) {     int digit1,digit2,digit3,digit4;     printf("Enter an encrypted 4-digit combination:");     scanf("%d%d%d%d \n",&digit1,&digit2,&digit3,&digit4);    digit1=(digit4);     digit2=(9-digit2);     digit3=(9-digit3);     digit4=(digit1);     printf("The real combination is:");     printf("%d%d%d%d",&digit1,&digit2,&digit3,&digit4);     return 0; }```
• 09-18-2012
The Doctor
Here's a problem:

Code:

```digit1=(digit4); /*Why do you have brackets here, by the way? They aren't necessary. */ /*SNIP*/ digit4 =(digit1);```
Digit1 would become the same value as digit4, and digit4 would remain unchanged. (Technically, it would become the same value as digit 1, which has actually been changed to the value that digit4 is already)

Try to work out a way around this.
• 09-18-2012
Click_here
Quote:

Originally Posted by Noor
I am meant to encrypt a 4-digit combination the last and first digits should be swapped and 9 should be subtracted from the second and third digit. I don't know if this is right though could someone please guide me :)

Code:

```#include <stdio.h> int main(void) {     int digit1,digit2,digit3,digit4;     printf("Enter an encrypted 4-digit combination:");     scanf("%d%d%d%d \n",&digit1,&digit2,&digit3,&digit4);     digit1=(digit4);     digit2=(9-digit2);     digit3=(9-digit3);     digit4=(digit1);     printf("The real combination is:");     printf("%d%d%d%d",&digit1,&digit2,&digit3,&digit4);     return 0; }```

You should start a new forum topic each time you have a new question.

It's good to see that you have code this time :)
Code:

`scanf("%d %d %d %d",&digit1,&digit2,&digit3,&digit4);`
Might be a good start :)
• 09-18-2012
Click_here
Oh, and
Code:

`printf("%d%d%d%d",&digit1,&digit2,&digit3,&digit4);`
should be something like this -
Code:

`printf("\n%d %d %d %d", digit1, digit2, digit3, digit4);`
Otherwise printf will try to print out the address of the variables.
• 09-18-2012
Salem
Regardless of whether you have
scanf("%d %d %d %d"
or
scanf("%d%d%d%d"

you will need to type in
1 2 3 4
rather than
1234
• 09-18-2012
Click_here
Quote:

Originally Posted by Salem
Regardless of whether you have
scanf("%d %d %d %d"
or
scanf("%d%d%d%d"

you will need to type in
1 2 3 4
rather than
1234

No disagreement there - But OP will need to loose the new line character
• 09-19-2012
Noor
Why wont this work?
Code:

```#include <stdio.h> int main(void) { int digit1,digit1,digit3,digit4; printf("Enter an encrypted 4-digit combination:"); scanf("%d%d%d%d \n",&digit1,&digit2,&digit3,&digit4); digit1=digit1+digit4; digit2=9-digit2; digit3=9-digit3; digit4=digit1-digit4; digit1=digit1-digit4; printf("The real combination is:"); scanf("%d%d%d%d",digit1,digit2,digit3,digit4); return 0; }```
• 09-19-2012
Salem
> scanf("%d%d%d%d \n",&digit1,&digit2,&digit3,&digit4);
The first thing to do is remove the trailing whitespace from your scanf. It doesn't do what you think it does.

So perhaps
scanf("%d%d%d%d",&digit1,&digit2,&digit3,&digit4);

Next, you need to type in say
1 2 3 4
as opposed to say
1234

That is, you need a space between each digit.

Having done that, if it still doesn't work, then you need to be more specific than "it doesn't work".

For example, by showing us what you typed in, and the results (or lack of) that you observed.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last