60 429
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #63100 in C for ranga

Question #63100
If there is a space to park the vechiles then some n number of vechiles are parked there and then count how many are of cars, and how many of are scooters and note the arrival time and the departure time, display the order of parked vechiles, and the color of vechile,if he wants to take the vehicle from the parking he has to tell the number of vehicle if the number is wrong he can’t able to take the vehicle from parking in that case he has to tell the car model and the color of vehicle and also the rc book of vehicle and also he has to calculate the parking fees based on time he kept.
Expert's answer

Mail
COMPOSE
Labels
Inbox (1,485)
Starred
Sent Mail
Drafts
INBOX/answer provision
INBOX/Biology (853)
INBOX/Chemistry (3,433)
INBOX/comments (1,252)
INBOX/consideration
INBOX/Economics_Marketing_Management (2,150)
INBOX/Math (1,600)
INBOX/old WRITING (2,092)
INBOX/Physics_Engineering (4,783)
INBOX/Programming (2,857)
INBOX/validation
Junk Email
More
Chat
questions - globalfreelance.ua

Search people...
bovhyra
gala.rilina
i_van_go
perpetuum.kolya
sadjester
sm.jane05
v.glad2010
zoialife
Евгения Сморцова
Коля Полюхович

Move to Inbox More
2 of 4

Print all In new window
Answer on Question #63100, Programming & Computer Science / C
Inbox
x

Vladimir Goncharov
AttachmentsNov 3 (1 day ago)

to me
Attachments area

Click here to Reply or Forward
Using 6.5 GB
Manage
Program Policies
Powered by Google
Last account activity: 1 minute ago
Open in 2 other locations Details
Vladimir Goncharov
Join Google+

Show details



#include <stdio.h>
#include <string.h>

typedef struct {
int hh; //hours
int mm; //minutes
} time;

typedef struct {
int number;
char type[255];
char color[255];
char model[255];
time arrival;
time departure;
} vehicle;

time makeTime(int a, int b) {
time res;
res.hh = a, res.mm = b;

return res;
}

vehicle readVehicle() {
vehicle res;
int a, b;
char s[255];


printf("Enter vehicles number: ");
scanf("%d", &a);
res.number = a;

printf("Enter vehicles type: ");
scanf("%s", &s);
strcpy(res.type, s);

printf("Enter vehicles color: ");
scanf("%s", &s);
strcpy(res.color, s);

printf("Enter vehicles model: ");
scanf("%s", &s);
strcpy(res.model, s);

printf("Enter arrival time: ");
scanf("%d:%d", &a, &b);
res.arrival = makeTime(a, b);

printf("Enter departure time: ");
scanf("%d:%d", &a, &b);
res.departure = makeTime(a, b);

return res;
}

void printVehicle(vehicle a) {
printf("Vehicle number: %d. ", a.number);
printf("Vehicle type: %s. ", a.type);
printf("Vehicle color: %s. ", a.color);
printf("Vehicle model: %s\n", a.model);

printf("Arrival time: %d%d:%d%d. ", a.arrival.hh / 10, a.arrival.hh % 10, a.arrival.mm / 10, a.arrival.mm % 10);
printf("Departure time: %d%d:%d%d\n", a.departure.hh / 10, a.departure.hh % 10, a.departure.mm / 10, a.departure.mm % 10);
}

int main() {
int n, i, t;
printf("Please, enter number of vehicles: ");
scanf("%d", &n);

vehicle *a = malloc(sizeof(vehicle)*n);

for (i = 0; i < n; i++) {
printf("Please, enter vehicle #%d: \n", i + 1);

a[i] = readVehicle();
}

int numberOfCars = 0, numberOfScooters = 0;

for (i = 0; i < n; i++) {
printVehicle(a[i]);

if (strcmp(a[i].type, "car") == 0) {
numberOfCars++;
}
if (strcmp(a[i].type, "scooter") == 0) {
numberOfScooters++;
}
}

printf("Number of cars: %d. Number of scooters: %d\n", numberOfCars, numberOfScooters);

return 0;
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions