1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
boyakko [2]
3 years ago
13

Define a structure type auto_t to represent an automobile. Include components for the make and model (strings), the odometer rea

ding, the manufacture and purchase dates (use another user-defined type called date_t), and the gas tank (use a user-defined type tank_t with components for tank capacity and current fuel level, giving both in gallons). Write I/O functions scan_date, scan_tank, scan_auto, print_date, print_tank, and print_auto, and also write a driver function that repeatedly fills and displays an auto structure variable until EOF is encountered in the input file.
Computers and Technology
1 answer:
yulyashka [42]3 years ago
8 0

Answer:

see explaination

Explanation:

#include <stdio.h>

#include <string.h>

#define BUFSIZE 1000

struct auto_t scan_auto(char *);

struct date_t {

char day[2];

char month[2];

char year[4];

};

struct tank_t {

char tankCapacity[10];

char currentFuelLevel[10];

};

struct auto_t {

char make[50];

char model[50];

char odometerReading[10];

struct date_t manufactureDate;

struct date_t purchaseDate;

struct tank_t gasTank;

};

int main(int argc, char *argv[]) {

/* the first command-line parameter is in argv[1]

(arg[0] is the name of the program) */

FILE *fp = fopen(argv[1], "r"); /* "r" = open for reading */

char buff[BUFSIZE]; /* a buffer to hold what you read in */

struct auto_t newAuto;

/* read in one line, up to BUFSIZE-1 in length */

while(fgets(buff, BUFSIZE - 1, fp) != NULL)

{

/* buff has one line of the file, do with it what you will... */

newAuto = scan_auto(buff);

printf("%s\n", newAuto.make);

}

fclose(fp); /* close the file */

}

struct auto_t scan_auto(char *line) {

int spacesCount = 0;

int i, endOfMake, endOfModel, endOfOdometer;

for (i = 0; i < sizeof(line); i++) {

if (line[i] == ' ') {

spacesCount++;

if (spacesCount == 1) {

endOfMake = i;

}

else if (spacesCount == 2) {

endOfModel = i;

}

else if (spacesCount == 3) {

endOfOdometer = i;

}

}

}

struct auto_t newAuto;

int count = 0;

for (i = 0; i < endOfMake; i++) {

newAuto.make[count++] = line[i];

}

newAuto.make[count] = '\0';

count = 0;

for (i = endOfMake+1; i < endOfModel; i++) {

newAuto.model[count++] = line[i];

}

newAuto.model[count] = '\0';

count = 0;

for (i = endOfModel+1; i < endOfOdometer; i++) {

newAuto.odometerReading[count++] = line[i];

}

newAuto.odometerReading[count] = '\0';

return newAuto;

}

You might be interested in
What are some signs that could help you determine that a date and time was inserted as a special object instead of
Jlenok [28]

Answer:

i) It is difficult to put the mouse pointer's insertion point in the text

ii) A gray border appear around the time and date when you point to it

Explanation:

When the date and time is pointed to or hovered using the mouse pointer, we have, that the background of the text changes to a grey border around the text when the date and time is inserted as a special object using the insert date and time button on the insert menu in the word processing application

The mouse pointer behaves different when working with some applications, and it could be difficult to place the insertion point of the mouse pointer in the  text

Therefore, the correct options are;

<em>It is difficult to put the mouse pointer's insertion point in the text and</em>

<em>A gray border appear around the time and date when you point to it.</em>

3 0
2 years ago
Consider the following code segment: theSum = 0.0 while True: number = input("Enter a number: ") if number == ": break theSum +=
Strike441 [17]

n where n is the number of chances user takes to enter a blank number and n>=1.

<u>Explanation:</u>

The loop starts with a universal condition where it is initialized using a true value. Hence the iteration count goes to 1. The user is asked to enter a number after 1st iteration. If number is a blank number, the loop is terminated, else the loop goes on until the users enters a blank number. Hence the iterations depend on the number of chances taken by the user to enter a blank number. Since the user is going to enter a number at least once, the minimum value of n will be 1.

4 0
3 years ago
In a non-price rationing system, consumers receive goods and services first-come, first served. Give me an example of a time whe
Anna35 [415]

When someone may be giving away something for free.

7 0
2 years ago
Write a program that accepts a phrase of unspecified length on the command line. For example: prompt% letter print Operating Sys
Sedaia [141]

Answer:

Check the explanation

Explanation:

#define _MULTI_THREADED

#include <pthread.h>

#include <stdio.h>

#include <errno.h>

#define           THREADS          2

int               i=1,j,k,l;

int argcG;

char *argvG[1000];

void *threadfunc(void *parm)

{

int *num;

num=(int*)parm;

while(1)

   {

   if(i>=argcG)

   break;

   if(*num ==1)

   if(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u')

   {

   printf("%s\n",argvG[i]);

   i++;

   continue;

   }

    if(*num ==2)

   if(!(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u'))

   {

   printf("%s\n",argvG[i]);

   i++;

   continue;

   }

   sched_yield();

   }

return NULL;

}

int main(int argc, char *argv[])

{

pthread_t            threadid[THREADS];

int                  rc=0;

int                  loop=0;

int arr[2]={1,2};

argcG=argc;

for(rc=0;rc<argc;rc++)

argvG[rc]=argv[rc];

printf("Creating %d threads\n", THREADS);

for (loop=0; loop<THREADS; ++loop) {

     rc =pthread_create(&threadid[loop], NULL, threadfunc,&arr[loop]);

}

for (loop=0; loop<THREADS; ++loop) {

   rc = pthread_join(threadid[loop], NULL);

}

printf("Main completed\n");

return 0;

}

The below attached image is a sample output

3 0
3 years ago
Again, suppose that n and r denote integer values where r &gt; 0 and n ≥ 0. What are two "simple" values, say lowEnough and tooH
enyata [817]

Answer:

Answer explained

Explanation:

From the previous question we know that while searching for n^(1/r) we don't have to look for guesses less than 0 and greater than n. Because for less than 0 it will be an imaginary number and for rth root of a non negative number can never be greater than itself. Hence lowEnough = 0 and tooHigh = n.

we need to find 5th root of 47226. The computation of root is costlier than computing power of a number. Therefore, we will look for a number whose 5th power is 47226. lowEnough = 0 and tooHigh = 47226 + 1. Question that should be asked on each step would be "Is 5th power of number < 47227?" we will stop when we find a number whose 5th power is 47226.

6 0
2 years ago
Other questions:
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
    5·1 answer
  • Given the following adjacency matrix, what is the approximate rank vector after one iteration of the power iteration method (use
    10·1 answer
  • Consider the following scheduling problem. You are given a list of final exams F1,...,Fk tobescheduled,andalistofstudentsS1,...,
    10·1 answer
  • A stack is initially empty, then the following commands are performed: push 5, push 7, pop, push 10, push 5, pop, which of the f
    8·1 answer
  • Who were called “freedmen” during the reconstruction period?
    15·2 answers
  • 4-One possible performance multiplication enhancement is to do a shift and add instead of an actual multiplication. Since 9 * 6,
    12·1 answer
  • Join my discord server! CODE IS (CebjBXN)​
    12·2 answers
  • 17. Ano ang tawag sa pahina ng Excel?
    12·1 answer
  • 2.2 Write an interactive C# program that asks the user to input an integer number. The program checks whether the number entered
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!