:cheesy: Bit of a cheek I know but can anyone write some code for in C using if statements for the following:

1. "A man is paid the hourly rate of £10 per hour for the first 40 hours worked. After that, overtime is paid at 1.5 times the hourly rate for the next 30 hours worked and twice the hourly rate for further hours worked.

The 'if' statement needs to show number of hours worked, calculate and display basic pay, overtime pay and final gross pay."

And... if you're feeling really generous with your knowledge tonight... :eek:

2. "A car costs a certain amount. If it is silver there is an extra charge of £300. If it is an XL model there is an extra charge of £500.

The code needs to enter the basic price of the car. Ask if it is silver and add the extra charge if appropriate. Then ask if it is an XL model and add this extra charge if appropriate. Finally display the total price."


3. "A man has estabished the following set of rules for deciding what clothing to wear to enable him to walk to work comfortably in all weathers in the Spring:

- if the barometer indicates storm he wears his overcoat and hat
- if the barometer indicates rain he wears his raincoat and takes an umbrella
- if the barometer indicates change he bahaves as for fair if it rained yesterday and as for rain if it did not
- if fair is indicated he wears light over-jacket and takes an umbrella
- if very dry is indicated he wears light over-jacket

The code needs to input a coded barometer reading and whether it rained yesterday (where necessary), and the type of clothing he should wear."

Cheers!
:lol:

Recommended Answers

All 3 Replies

Hello, this is the wrong forum for support questions. You should post your question's regarding C in the C/C++. That is : Software Development -> C/C++.

And regarding you question, it's not entirely clear. How are you suppose to find out what the data is? Just guess?

The following is C++ code, but I guess you only need to change the cout statement:

//do headers yourself :P

int hour, salary;
if (hour < 41) {salary = hour * 10;}
if (hour > 40 && hour < 71){salary = 40 * 10 + (hour - 40) *  (1.5 *  10);}
if (hour > 70){salary = 40 * 10 + 30 * (1.5 * 10) + (hour - 70) * 20;}

Take this as example and you will be able to figger the rest out.

That was a real help! Thank you very much.
:cheesy:

That was a real help! Thank you very much.
:cheesy:

by the looks of those questions im guessing school of college work? lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.