answer.
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]
2 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]2 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
"There are no longer mature industries; rather, there are mature ways of doing business," he is referring to the high demand of
yanalaym [24]

Hi, you've asked an incomplete and unclear question. However, I provided the full text below.

Explanation:

The text reads;

<em>"When Porter says “There are no longer mature industries; rather, there are mature ways of doing business,” he is referring to the high demand for creativity and innovation in the market. Earlier we used to be more concerned about the hardware and the physical product rather than its information content, But now as a business, we need to provide more informative content with the product.</em>

<em>Like General Electric offers dedicated customer service for its line of goods which differentiates it from its rivals. Similarly, shipping companies like UPS now offer us to track the location of our package on a live map. This is what we call a mature business and how we can differentiate ourselves and stand out in the highly competitive market by using Information and Technology..."</em>

4 0
2 years ago
Which of the following option is correct about HCatalog?
adell [148]

Answer:

Option (3) is the correct answer of this question.

Explanation:

  • HCatalog makes available Hive metadata to users of other Hadoop applications, such as Pig, MapReduce and Hive. it offers interfaces for MapReduce and Pig so that users can read data from and write data to the Hive warehouse.
  • This means users don't have to care about where or in what format their data is stored. So we know this way that Hcatalog makes sure our data is secure.
  • Others option does not belong to Hcatalog so these options are incorrect .

8 0
2 years ago
Modify the TimeSpan class from Chapter 8 to include a compareTo method that compares time spans by their length. A time span tha
My name is Ann [436]

Answer:

Check the explanation

Explanation:

Here is the modified code for

TimeSpan.java and TimeSpanClient.java.

// TimeSpan.java

//implemented Comparable interface, which has the compareTo method

//and can be used to sort a list or array of TimeSpan objects without

//using a Comparator

public class TimeSpan implements Comparable<TimeSpan> {

   private int totalMinutes;

   // Constructs a time span with the given interval.

   // pre: hours >= 0 && minutes >= 0

   public TimeSpan(int hours, int minutes) {

        totalMinutes = 0;

        add(hours, minutes);

   }

   // Adds the given interval to this time span.

   // pre: hours >= 0 && minutes >= 0

   public void add(int hours, int minutes) {

        totalMinutes += 60 * hours + minutes;

   }

   // Returns a String for this time span such as "6h15m".

   public String toString() {

        return (totalMinutes / 60) + "h" + (totalMinutes % 60) + "m";

   }

   // method to compare this time span with other

   // returns a negative value if this time span is shorter than other

   // returns 0 if both have same duration

   // returns a positive value if this time span is longer than other

   public int compareTo(TimeSpan other) {

        if (this.totalMinutes < other.totalMinutes) {

            return -1; // this < other

        } else if (this.totalMinutes > other.totalMinutes) {

            return 1; // this > other

        } else {

            return 0; // this = other

        }

   }

}

// TimeSpanClient.java

public class TimeSpanClient {

   public static void main(String[] args) {

        int h1 = 13, m1 = 30;

        TimeSpan t1 = new TimeSpan(h1, m1);

        System.out.println("New object t1: " + t1);

        h1 = 3;

        m1 = 40;

        System.out.println("Adding " + h1 + " hours, " + m1 + " minutes to t1");

        t1.add(h1, m1);

        System.out.println("New t1 state: " + t1);

        // creating another TimeSpan object, testing compareTo method using the

        // two objects

        TimeSpan t2 = new TimeSpan(10, 20);

        System.out.println("New object t2: " + t2);

        System.out.println("t1.compareTo(t2): " + t1.compareTo(t2));

        System.out.println("t2.compareTo(t1): " + t2.compareTo(t1));

        System.out.println("t1.compareTo(t1): " + t1.compareTo(t1));

   }

}

/*OUTPUT*/

New object t1: 13h30m

Adding 3 hours, 40 minutes to t1

New t1 state: 17h10m

New object t2: 10h20m

t1.compareTo(t2): 1

t2.compareTo(t1): -1

t1.compareTo(t1): 0

4 0
2 years ago
In the context of a global information system (gis), _____ offer electronic data interchange standards, encryption, secure e-mai
vaieri [72.5K]

Answer:

The correct option to the following question is b.) value-added networks.

Explanation:

A Van, or the value-added network, involves the use of the common carrier's that is phone line to allows the business to business network communications.

Network is the “value-added” because they have various services and the enhancements which improve the way of the business applications which communicate with each other.

8 0
2 years ago
Which of the following is ideal for long distance communication ?
Vinvika [58]
Microwave transmission is ideal for long distance communication. It is so good that it is used for satellite and space probe communication.
3 0
2 years ago
Other questions:
  • Which of the following is NOT a method in which a macro can be run?
    10·1 answer
  • A database design where certain data entities are combined, summary totals are carried in the data records rather than calculate
    5·1 answer
  • Which is the term for a computer typically located in an area with limited security and loaded with software and data files that
    9·1 answer
  • Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
    8·1 answer
  • PYTHON CODE ONLY:
    7·1 answer
  • NOTE: in mathematics, division by zero is undefined. So, in C++, division by zero is always an error. Given a int variable named
    9·1 answer
  • Describe the indicators and hazards of a metal deck roof fire in an unprotected steel joist warehouse as well as the techniques
    6·1 answer
  • The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private fi
    6·1 answer
  • Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount. Each parameter is of type int. The fu
    13·1 answer
  • In which of the security mechanism does the file containing data of the users/user groups have inbuilt security?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!