Question 3.
Write a program that contains the following functions a) A function that takes in as input the amount a person has to pay to buy a house, and the monthly payments made. Your function should display how much has been payed and how much is left to pay every month until the mortgage has been payed (Ignore interest and the like) b) A function that takes in as input the color of a car, and returns the number of cars of that color present in a file that contains the color of cars parked in a lot. Create the file, and put in color of cars (the number of entries doesn't matter, but make sure there is repetition) E.g Blue Red Blue Green Black Red ............. and so on c) A function that returns the color of car that is most present in the parking lot d) A function that takes in two colors as input and returns the total number of cars with both colors. For example, if there are 7 blue cars and 5 silver cars, your function should return 12.
Dear student, according to the question, the solution is as follows:
Program:
#include <iostream>
#include <fstream>
#include <unistd.h>
#include<string.h>
using namespace std;
int NumberofColorCars(char*);
int NumberofColorCars2(char*,char*);
void houseMonthlyPayments(int,int);
int main()
{
houseMonthlyPayments(120000,3);
cout<<"No. of cars of color Blue are :
"<<NumberofColorCars("Blue")<<endl;
cout<<"No. of cars of color Blue and color Red are :
"<<NumberofColorCars2("Blue","Red");
return 0;
}
int NumberofColorCars(char *color)
{
std::ifstream myfile("Carcolors.txt");
if ((!myfile))
{
std::cout << "Failed to open file\n";
exit(1);
}
char ch[100];
int count =0;
while(myfile>>ch)
{
if((strcmp(ch,color)) == 0)
{
count++;
}
}
return count;
}
int NumberofColorCars2(char *color1,char *color2)
{
std::ifstream myfile("Carcolors.txt");
if ((!myfile))
{
std::cout << "Failed to open file\n";
exit(1);
}
char ch[100];
int count = 0;
while(myfile>>ch)
{
if( (strcmp(ch,color1) == 0) || (strcmp(ch,color2)) == 0 )
{
count++;
}
}
return count;
}
void houseMonthlyPayments( int bought, int n)
{
// Assuming 12 months installment.
int installment = bought / 12;
int paid = (n * installment);
int left = (bought - paid) / (12 - n);
cout << "Bought @ : " <<bought<<endl;
cout << "Paid till now : " <<paid<<endl;
cout << "Total no. of months to be paid :" <<(12-
n)<<endl;
cout << "Left to pay every month :"
<<left<<endl;
cout<<endl;
}
Output:

first 4 lines represent part a) function
5th line represent part b) function
6th line represents part d) function

Sorry for the inconvenience, I couldn't able to complete part C function.
Thank you, All the best.
Question 3. Write a program that contains the following functions a) A function that takes in...
A function that takes in as input the colour of a car, and returns the number of cars of that colour present in a file that contains the colour of cars parked in a lot. Create the file, and put in colour of cars (the number of entries doesn't matter, but make sure there is repetition) E.g Blue Red Blue Green Black Red ............. and so on
c++ language Write a program that contains the following functions, i. A function isVowel that takes in a character and returns true if it is a vowel and false otherwise ii. A function that request from the user to enter in a sequence of characters, and outputs the number of vowels entered. (Use Function in a) to assist you, a sentinel value can be used to specify the end of the user input iii. A function that reads 3 test...
Write a program to run the following methods in C#. 2) Write a method that takes in a teacher’s last name and exam number via parameters. Ask the teacher (using her name) to tell you the highest score on that exam. Your question should look something like “Ms. Jones, what was the highest grade on test two?” Return the value of the highest grade to the calling method. 3) Write a function called MinOfThree that takes in three numbers and...
The Bashemin Parking Garage contains a single lane that can hold up to ten cars. Arriving cars enter the garage at the rear and are parked in the empty space nearest to the front. Departing cars exit only from the front. If a customer needs to pick up a car that is not nearest to the exit, then all cars blocking its path are moved out temporarily, the customer's car is driven out, and the other cars are restored in...
using java:
For this exercise, you will design a set of classes that work
together to simulate a parking officer checking a parked car
issuing a parking ticket if there is a parking violation. Here are
the classes that need to collaborate:
• The ParkedCar class: This class should
simulate a parked car. The car has a make, model, color, license
number. •The ParkingMeter class: This class should
simulate a parking meter. The class has three parameters:
− A 5-digit...
Write a Python function makeDict() that takes a filename as a parameter. The file contains DNA sequences in Fasta format, for example: >human ATACA >mouse AAAAAACT The function returns a dictionary of key:value pairs, where the key is the taxon name and the valus is the total number of 'A' and 'T' occurrences. For example, for if the file contains the data from the example above the function should return: {'human':4,'mouse':7}
For this assignment you will design a set of classes that work together to simulate a police officer issuing a parking ticket. The classes you should designare:• The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are:o To know the car’s make, model, color, license number, and the number of minutes that the car has been parked• The ParkingMeter Class: This class should simulate a parking meter. The class’s only responsibility is:o To know the number...
This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...
Write a function called char_counter that counts the number of a certain character in a text file. The function takes two input arguments, fname, a char vector of the filename and character, the char it counts in the file. The function returns charnum, the number of characters found. If the file is not found or character is not a valid char, the function return -1. As an example, consider the following run. The file "simple.txt" contains a single line: "This...
Write a complete program that uses the functions listed below. Except for the printOdd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention to the order of your function calls. Be sure to read in data from the input file. Using the input file provided, run your program to generate an output file. Upload the output file your program generates. •Write a...