Question

In: Computer Science

Designed a Flowchart where you have to ask road type and speed of the vehicle from...

Designed a Flowchart where you have to ask road type and speed of the vehicle from user
and then decide whether a car is over-speeding, is under-speed or it is moving with the allowed
speed. Develop program using C language The allowed speed limit is given in the following table.
See the following conditions:

Road Type     Speed Limit
Local Street 20-30 km/h
Main Street   31-40 km/h
Main Road    41-90 km/h
High way       91-110 km/h

Table 2: Normal (Allowed)

Solutions

Expert Solution

Flow chart:

Code:

#include <stdio.h>
int main(){
   //variables to store road tye and speed
   int road_type;
   int speed;
   //taking input from user
   printf("1.Local Street\n2.Main Street\n3.Main Road\n4.High way\nEnter Road type: ");
   scanf("%d",&road_type);
   printf("Enter speed: ");
   scanf("%d",&speed);
   //slection statements based on given conditions
   //if any invalid input is entered then error is printed
   if(road_type==1){
       if(speed<=30 && speed>=20){
           printf("Moving in Normal speed");
          
       }
       else if(speed<20){
           printf("under speed");
       }
       else if(speed>30){
           printf("Over speed");
       }
       else{
           printf("error");
       }
   }
   else if(road_type==2){
       if(speed<=40 && speed>=31){
           printf("Moving in Normal speed");
          
       }
       else if(speed<31){
           printf("under speed");
       }
       else if(speed>40){
           printf("Over speed");
       }
       else{
           printf("error");
       }
   }
   else if(road_type==3){
       if(speed<=90 && speed>=41){
           printf("Moving in Normal speed");
          
       }
       else if(speed<41){
           printf("under speed");
       }
       else if(speed>90){
           printf("Over speed");
       }
       else{
           printf("error");
       }
   }
   else if(road_type==4){
       if(speed<=110 && speed>=91){
           printf("Moving in Normal speed");
          
       }
       else if(speed<91){
           printf("under speed");
       }
       else if(speed>110){
           printf("Over speed");
       }
       else{
           printf("error");
       }
   }
   else{
       printf("Error");
   }
      
   }

Output:

Code Screenshot:

Code Snippet:

#include <stdio.h>
int main(){
        //variables to store road tye and speed
        int road_type;
        int speed;
        //taking input from user
        printf("1.Local Street\n2.Main Street\n3.Main Road\n4.High way\nEnter Road type: ");
        scanf("%d",&road_type);
        printf("Enter speed: ");
        scanf("%d",&speed);
        //slection statements based on given conditions
        //if any invalid input is entered then error is printed
        if(road_type==1){
                if(speed<=30 && speed>=20){
                        printf("Moving in Normal speed");
                        
                }
                else if(speed<20){
                        printf("under speed");
                }
                else if(speed>30){
                        printf("Over speed");
                }
                else{
                        printf("error");
                }
        }
        else if(road_type==2){
                if(speed<=40 && speed>=31){
                        printf("Moving in Normal speed");
                        
                }
                else if(speed<31){
                        printf("under speed");
                }
                else if(speed>40){
                        printf("Over speed");
                }
                else{
                        printf("error");
                }
        }
        else if(road_type==3){
                if(speed<=90 && speed>=41){
                        printf("Moving in Normal speed");
                        
                }
                else if(speed<41){
                        printf("under speed");
                }
                else if(speed>90){
                        printf("Over speed");
                }
                else{
                        printf("error");
                }
        }
        else if(road_type==4){
                if(speed<=110 && speed>=91){
                        printf("Moving in Normal speed");
                        
                }
                else if(speed<91){
                        printf("under speed");
                }
                else if(speed>110){
                        printf("Over speed");
                }
                else{
                        printf("error");
                }
        }
        else{
                printf("Error");
        }
                
        }

Related Solutions

A single lane road is designed for a speed of 75kmph having a two-way traffic with...
A single lane road is designed for a speed of 75kmph having a two-way traffic with radius of 350m. Determine the following (use different reaction time for question i, ii & iii). Stopping Sight Distance for plain road. Stopping Sight Distance for ascending and descending gradient of 1/75. Overtaking sight distance. (take interpolated value for ‘a’) Sketch of maximum overtaking zone distance and sign posts. Setback distance for SSD (only plain road) and OSD for curve length of 150m and...
You stand on a straight desert road at night and observe a vehicle approaching. This vehicle...
You stand on a straight desert road at night and observe a vehicle approaching. This vehicle is equipped with two small headlights that are 0.621m apart. At what distance, in kilometers, are you marginally able to discern that there are two headlights rather than a single light source? Take the wavelength of the light to be 559nm and your pupil diameter to be 4.69mm. Answer in km!
You are thrown from a bicycle while riding at speed on a gravel road. Immediately you...
You are thrown from a bicycle while riding at speed on a gravel road. Immediately you start bleeding from several places where the gravel cut through your epidermis into your dermis and broke numerous blood vessels. Your body's first response to this injury is to begin the process known as [a]. This process has three steps. [b]: the [e] in the tunica media of your damaged blood vessels begins to contract, [f] blood flow to this portion of vessel, in...
Imagine a researcher collects data on drivers’ Gender, Type of Vehicle, and Speed of Travel. Which...
Imagine a researcher collects data on drivers’ Gender, Type of Vehicle, and Speed of Travel. Which measure of central tendency would be appropriate for each of these variables?
The city of Springville is considering to raise the speed limit on a certain road from...
The city of Springville is considering to raise the speed limit on a certain road from 60km/hour to 75km/hour. a) Identify one benefit and one cost that would result from this change in speed limit. b) Identify the simple or complex method that can be used to monetize each impact that you have mentioned in part ‘a’. Briefly explain the methods. c) Are there reasons why the CBA Analyst should be cautious about any of the approaches that you explained...
Residents are concerned about the speed of vehicles traveling on that road. Drivers seem to have...
Residents are concerned about the speed of vehicles traveling on that road. Drivers seem to have a tendency to drive at high speeds on their way out of and into town, even though the speed limit is only 25 mph. Police officers often record the speeds of the vehicles and ticket those who are found to be speeding.  the speeds from a sample of 33 vehicles recorded throughout one weekday : 24 25 26 27 27 27 28 28 28 29...
Every road has one at some point - construction zones that have much lower speed limits....
Every road has one at some point - construction zones that have much lower speed limits. To see if drivers obey these lower speed limits, a police officer uses a radar gun to measure the speed (in miles per hours, or mph) of a random sample of 10 drivers in a 25 mph construction zone. Here are the data: 27; 33; 32; 21; 30; 30; 29; 25; 27; 34. Is there convincing evidence that at the α=0.01 significance level that...
If you buy an automobile, the law requires you to have insurance for that vehicle. Explain...
If you buy an automobile, the law requires you to have insurance for that vehicle. Explain the difference between liability auto insurance and full coverage auto insurance. Which insurance would you select for a new car? Why?
Please type where possible and be very neat. You have 1 M solutions of formic acid...
Please type where possible and be very neat. You have 1 M solutions of formic acid and sodium formate. Calculate the volume of sodium formate required to make 1 liter of a solution with a pH of 4.1 in which the concentration of formic acid is 0.15 M. The pKa of formic acid is 3.75. Using the Henderson-Hasselbalch equation, explain why the pH of a solution of a weak acid and its conjugate base does not change upon dilution.
PLEASE TYPE!! Think about where you have noticed circles in your everyday life and find at...
PLEASE TYPE!! Think about where you have noticed circles in your everyday life and find at least 2 examples of circles in your everyday life. For each example, include the following in your post. Be sure to include enough details in your descriptions and explanations so someone who is not familiar with your everyday life will understand them. Describe the circle's use and its measurement (radius or diameter, either an exact value or an approximation is fine). If important, describe...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT