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
Which file type is the best choice if the image will be made into a billboard?
matrenka [14]

Answer:

BMP

Explanation:

They are high resolution and are suitable for billboards.

6 0
1 year ago
You were just hired as an IT Specialist for Smalltown School District. Your first assignment is to review a problem area&amp; in
umka21 [38]

Answer:

Explanation:

There are various questions that you can ask in this scenario, such as

What grading policies are being implemented?

How many student grades are being calculated by the program?

What is the requirements for a student to pass?

All of these questions would allow you to get an idea of how extensive the code may be and its complexity. Once you know this you would look at the code revolving around actually looping through the data and doing the necessary calculations. You can then determine how to manipulate the code and make it much more efficient.

You would also need to know how the student data is being saved, which will help determine if it is the best data structure for saving this type of data or if it can be replaced in order to maintain the data secure while increasing the speed of the program. Mainly since this information needs to be continuously used from the data structure.

3 0
3 years ago
Live footage refers to:
QveST [7]

Answer:

D

Explanation:

live refers to happening right now and footage refers to videos taken and captured.

8 0
1 year ago
A downloaded executable file may contain harmful software known as
mylen [45]

Answer:

A downloaded executable file may contain harmful software know as malware.

Further details:

Malwares:

Malware (a portmanteau for pernicious programming) is any product purposefully intended to make harm a PC, server, customer, or PC network. Malware does the harm after it is embedded or brought somehow or another into an objective's PC and can appear as legitimately executable code, contents, supposed "dynamic substance" (Microsoft Windows), and different types of data. Some sorts of malware are to a great extent alluded to in the media as PC infections, worms, Trojan steeds, ransomware, spyware, adware, and scareware, among different terms. Malware has a malignant expectation, acting against the enthusiasm of the PC client—thus does exclude programming that causes accidental damage because of some lack, which is regularly portrayed as a product bug.

Uses:

Malware is once in a while utilized comprehensively against government or corporate sites to assemble monitored information, or to upset their activity as a rule. However, malware can be utilized against people to pick up data, for example, individual recognizable proof numbers or subtleties, bank or charge card numbers, and passwords.

Answer details:

Subject: Computer and technology

Level: College

Keywords:

• Harmful software

• Malware

• Malware software

• Uses of malware

• Purpose of malware

Learn more to evaluate:

brainly.com/question/4997492

brainly.com/question/4010464

brainly.com/question/1754173

8 0
3 years ago
Read 2 more answers
1 #include 2 3 int max2(int x, int y) { 4 int result = y; 5 if (x &gt; y) { 6 result = x; 7 } 8 return result; 9 } 10 11 int max
Serhud [2]

Answer:

7

Explanation:

#include <stdio.h>

int max2(int x, int y) {

   int result = y;

   if (x > y) {

       result = x;

   }

   return result;

}

int max3(int x, int y, int z) {

   return max2(max2(x,y),z);

}

int main() {

   int a = 5, b = 7, c = 3;

   printf("%d",max3(a, b, c));

   printf("");

   return 0;

}

Hi, first of all, next time you post the question, it would be nice to copy and paste like above. This will help us to read the code easily. Thanks for your cooperation.

We start from the main function:

The variables are initialized → a = 5, b = 7, c = 3

max3 function is called with previous variables and the result is printed → printf("%d",max3(a, b, c));

We go to the max3 function:

It takes 3 integers as parameters and returns the result of → max2(max2(x,y),z)

Note that max2 function is called two times here (One call is in another call actually. That is why we need to first evaluate the inner one and use the result of that as first parameter for the outer call)

We go to the max2 function:

It takes 2 integers as parameters. If the first one is greater than the second one, it returns first one. Otherwise, it returns the second one.

First we deal with the inner call. max2(x,y) is max2(5,7) and the it returns 7.

Now, we need to take care the outer call max2(7, z) is max2(7, 3) and it returns 7 again.

Thus, the program prints 7.

6 0
2 years ago
Other questions:
  • Krystal recorded her times for all her cross-country meets this season. To sort her data showing the lowest times first, what wi
    14·2 answers
  • Marcus just created a new folder specifically for his buisness records so he would like to move last months business transaction
    13·2 answers
  • You are preparing to program a replacement system board, but the "system is booting in mpm mode" message is not displayed. what
    10·2 answers
  • In a ring-based system, procedure p is executing and needs to invoke procedure q. Procedure q's access bracket is (5,6,9). In wh
    15·2 answers
  • A difference between crt monitors and flat-panel displays is that most flat-panel displays use digital signals to display images
    8·1 answer
  • What is it called when two different files generate the same hashing result?
    15·1 answer
  • 3. Which of the following is called address operator?<br> a)*<br> b) &amp;<br> c).<br> d) %
    12·1 answer
  • Implement the Tollable interface. It provides one method, pay, that accepts an int (how many dollars to pay), and returns an int
    8·1 answer
  • All _______ that store more than one piece of data ​
    12·1 answer
  • In cells D6 through D8, enter formulas to calculate the values of the stocks. The formulas should multiply the number of shares
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!