The structure Car is declared as follows: struct Car { string carMake; string carModel; int yearModel; double cost; }; Write a definition statement that defines a Car structure variable initialized with the following data: Make: Ford Model: Mustang Year Model: 1968 Cost: $20,000
THEN Define an array of 25 of the Car structure variables
#include <iostream>
using namespace std;
struct Car {
string carMake;
string carModel;
int yearModel;
double cost;
};
int main() {
// Write a definition statement that defines a Car structure variable initialized with the following data
Car car;
car.carMake = "Ford";
car.carModel = "Mustang";
car.yearModel = 1968;
car.cost = 20000;
// THEN Define an array of 25 of the Car structure variables
Car cars[25];
return 0;
}
The structure Car is declared as follows: struct Car { string carMake; string carModel; int yearModel;...
struct my_coord { int x; int y; double altitude; }; struct my_line { struct my_coord first; struct my_coord second; char name[10]; }; struct my_coord var; struct my_coord array[3]; struct my_line one_line; struct my_line two_lines[2]; Draw the memory layout of the prior four variables; var, array, one_line, and two_lines on a line of boxes. Label the start of each variable and clearly show how many bytes each element within each structure variable consumes.
Use an accessor and mutator as follows: Remove the addFuel method from class Car Replace the call to addFuel in the main program with a call to the accessor and mutator for the fuel amount to achieve the same effect (add 5 gallons of fuel to the existing fuel in the Toyota Camry). Test your program again to make sure it works and produces the same output. Part 2: Add functions to remove duplicate code * In the main program,...
struct Item { string name; int quantity; float cost; }; const int MAX_SIZE = 50; class ManageInventory { public: ManageInventory() : count{0}, p_pInventoryItems {new Item*[size]} { } ManageInventory(int size) : size{size}, count{0}, p_pInventoryItems {new Item*[size]} { } ~ManageInventory(); void addItem(string name, int quantity, float cost); private: int size {MAX_SIZE}; int count; Item ** p_pInventoryItems; }; Write the definition for addItem. Use the new operator to dynamically create instances of type Item. Store pointers to inventory items in the inventoryItems array....
Declare a struct worker with the following attributes: char array first name string surname int age double salary. then , declare a structure my worker which is of type worker. ( read carefully, don,t make a mistake! ) one line is needed for the answer. in c programming
Assume an array list is declared as follows: int list[100] and that all other variables have been appropriately declared. Tell whether each of the following is a valid or invalid statement. If not valid explain why not. cin>>list[3]; cout<<list; x = list[3]+list[4]; list[10] = 3.2; cout<<list[3, 5, 22]; for (int i = 0; i < 100; i ++) cout<<list[i];
C++
Assume that you have a structure Node as follows: struct Node { int value; Node* next; Node(int v, Node* n = nullptr) { // constructor value = v; next = n; } }; Question 1 (20 points) Write a function "count" that counts the number of elements in a given linked list. The prototype of this function is as follows: int count_elements(Node*); Question 2 (20 points) Write a function “average" that calculates the average of all the elements in...
IN C PLEASE Question 16 A. Consider “inclass2.h” header file. Define a structure which can hold the following student information: id, first name, last name, and gpa. Use appropriate header file guards. ( Max size of first and last name is 20, id is 7 and gpa is double). B. Consider an array of student struct with the MAX_SIZE 10 and a first name. These will be provided as an input to your function. Write a function/method that using the...
A. Consider “inclass2.h” header file. Define a structure which can hold the following student information: id, first name, last name, and gpa. Use appropriate header file guards. ( Max size of first and last name is 20, id is 7 and gpa is double). B. Consider an array of student struct with the MAX_SIZE 10 and a first name. These will be provided as an input to your function. Write a function/method that using the given inputs prints out the...
Java Write a pair of serialization / deserialization apps that create a user’s Car list, w/ a class named Car, which includes model, VINumber (int), and CarMake (an enum, with valid values FORD, GM, TOYOTA, and HONDA) as fields. Use an array similar to the way the SerializeObjects did to handle several BankAccounts. Your app must include appropriate Exception Handling via try catch blocks (what if the file is not found, or the user inputs characters instead of digits for...
Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info for any number of cars. (You should not assume that it will always be seven lines in the input file). Use notepad to create input file "inData.txt". File should be stored in the same folder where all files from BlueJ for this program...