Question

In: Computer Science

In C, 1) Create variables for: your first and last name total round trip to school...

In C,

1) Create variables for:

your first and last name

total round trip to school and home (assuming you don't live on campus - make it your hometown).

cost of gas

2) Create a program that will:

output your first name and your total miles driven for the week.

output your last name with the total costs per week

Solutions

Expert Solution

Hi buddy, Please find the below C Program. I've added comments for your better understanding

#include <stdio.h>

int main(void) {
   // These two variables store the first name and last name respectively
   char first_name[20] = "Micheal";
   char last_name[20] = "Johnson";
   //Let's make the distance from home to school 2
   int distance = 2;
   //Let 'cost' be the cost of gas per mile
   double cost = 4;
   //Total miles per week is TOTAL_WEEK_DAYS (2) * DISTANCE * 2 (Both for Home to school and School to Home)
   int totalMiles = 5 * distance * 2;
   printf("%s %d\n",first_name,totalMiles);
   //Total cost will be total Miles * Cost per each mile
   double totalCost = totalMiles * cost;
   printf("%s %lf\n",last_name,totalCost);
   return 0;
}


OUTPUT:

Micheal 20
Johnson 80.000000


Related Solutions

Part 1: Create a character array and save your first and last name in it
PROGRAMMING IN C:Part 1:Create a character array and save your first and last name in itNote: You can assign the name directly or you can use the scanf function.Display your name on the screen.Display the address (memory location) in hexadecimal notation of the array. (hint: use %p)Use a for loop to display each letter of your name on a separate line.Part 2:Create a one dimensional array and initialize it with 10 integers of your choice.Create a function and pass the...
C# (Thank you in advance) Create an Employee class with five fields: first name, last name,...
C# (Thank you in advance) Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
c# language Create a class “Person” which included first name, last name, age, gender, salary, and...
c# language Create a class “Person” which included first name, last name, age, gender, salary, and havekids (Boolean) variables. You have to create constructors and prosperities for the class. Create a “MatchingDemo” class. In the main function, the program reads the number of people in the database from the “PersonInfo.txt” file and creates a dynamic array of the object. It also reads the people's information from “PersonInfo.txt” file and save them into the array. Give the user the ability to...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip date, customer number, customer last name, customer first name, and phone number for trips whose guide is Glory Unser or Susan Kiley. Show the SQL Server code for this view.
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John...
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John Dow will create table j_dow). You have to audit all DML statements on your table. To do this you write two triggers: 1. To log any DML statements that users might run on this table. The results must be stored in the First Initial _ Last Name _ Log table (e.g. John Dow will create table j_dow_log). The table should have unique event ID,...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
1. Variables can only be numbers. True or False 2. American Airlines reduced its round trip...
1. Variables can only be numbers. True or False 2. American Airlines reduced its round trip fare from Boston to New York by $45. The sale price was $139. What was the original price? Original price: 3. Joy Lindman, who works for GE, receives an annual salary of $85,000. Today she was informed by her boss that she will be receiving a $3,000 raise. What percent of her old salary is the $3,000 raise? (Round to nearest hundredth percent.) Raise...
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT