Answer to Question #12061 in C# for Candice

Question #12061
A circular racetrack is composed of 4 portions: concrete, mud, sand and asphalt.
Kevin's car takes 30 seconds to cross the concrete, 55 seconds to cross the mud, 47 seconds to cross the sand and 38 seconds to cross the asphalt. Dear Ma'am or Sir, please help me to create a program that would input a positive time value (in seconds) and output where in the track Kevin's car is after that specified time.Assume that the race starts at the beginning of the concrete. Moreover, the car go around the track more that once.
1
Expert's answer
2012-07-20T07:19:54-0400
int time=0;
time = int.Parse(Console.ReadLine());

while (time > 170) {
time = time - 170;

}
if ((time > 0) && (time <= 30))

{
Console.WriteLine("Concrete");

}
if((time>30) && (time<=85)) {

Console.WriteLine("Mud");
}
if ((time > 85)
&& (time <= 132))
{

Console.WriteLine("Sand");
}
if ((time > 132)
&& (time <= 170))
{

Console.WriteLine("Asphalt");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS