This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*6.12 (Parking Charges) A parking garage charges a $2.00 minimum fee to park for up to three | |
hours.The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three | |
hours. The maximum charge for any given 24 - hour period is $10.00. Assume that no car parks for | |
longer than 24 hours at a time. Write a program that calculates and prints the parking charges for each | |
of three customers who parked their cars in this garage yesterday. You should enter the hours parked | |
for each customer.Your program should print the results in a neat tabular formatand should calculate | |
and print the total of yesterday’s receipts.The program should use the function calculateCharges to | |
determine the charge for each customer.Your outputs should appear in the following format : | |
Car Hours Charge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*6.13 (Rounding Numbers) An application of function floor is to round a value to it's nearest | |
integer. The statement | |
y = floor(x + .5); | |
rounds the number x to the nearest integrand and assigns the result to y. Write a program that reads | |
several numbers and uses the preceding statement to round each of these numbers to the nearest | |
integer. For each number processed, print both the original number and the rounded number.*/ | |
// =============================================== 06-13 =============================================== // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*6.14 (Rounding Numbers) Function floor can be used to round a number to a specific decimal | |
place.The statement | |
y = floor(x * 10 + 0.5) / 10; | |
rounds x to the tenths position(the first position to the right of the decimal point).The statement | |
y = floor(x * 100 + 0.5) / 100; | |
rounds x to the hundredths position(the second position to the right of the decimal point).Write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// elaborated from https://github.com/Headturna/Examples/blob/master/Examples/Example34.cpp | |
#include<iostream> | |
// note arrays always pass by reference, so any change within the function modifies the passed array | |
void test1(int* (arr), int length) // passing a pointer to a function | |
{ | |
for (int i = 0; i < length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// ================================================== Prototypes ======================================================= // | |
void get(int* (&), int&); // function prototypes | |
void print(int*, int); | |
// ================================================== Source ========================================================== // | |
int main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// knight's tour problem using a one dimensional array | |
// https://support.sas.com/resources/papers/proceedings15/3060-2015.pdf | |
#include <iostream> | |
#include <array> | |
#include <vector> | |
#include <algorithm> | |
#include <fstream> | |
using namespace std; |