8: PGandE.cpp) Consider a gas and electric bill that sets two levels of use as follows: Electric 558 kwh $.223 /kwh $.281 /kwh Write a program that takes starting and ending readings for gas and electric meters and calculates charges to the nearest cent. Use one function to calculate charges for both gas and electric so as to eliminate duplicate calculations. Gas 10.1 therms Tier 1 quantities Tier 1 price Tier 2 Price $1.415 /therm $1.932 /therm
Q: 6. Write a function which takes only your full name as input and finds the total number of vowels in…
A: Please find the program to display count and vowels in the given input name:
Q: Q2: Write C++ program to read student mark as integer type and prints out its corresponding grade…
A: #include<iostream> using namespace std; //grade function void grade(int m){ if(m>=90…
Q: Program 2: Write overloaded function for calculating the area of square and rectangle named area(int…
A: #include<iostream> using namespace std; // in overloaded function names are same but arguments…
Q: 5.18 LAB: Count characters - functions Write a program whose input is a character and a string, and…
A: Create a 2 variable of type character and string Then take user input in main method After that…
Q: Create a function that takes in three arguments (prob, prize, pay) and returns trueif prob * prize >…
A: def profitable_gamble(prob,prize,pay): print(bool(prob*prize>pay)) profitable_gamble(4,5,25)…
Q: Assume a function F1 is defined with the heading: int F1(int a, double &b, double t[]); Assume…
A: function heading int F1(int a, double &b, double t[]); and variables defined are : int a1:…
Q: d) Two numbers num1,num2 are passed as parameters to a function named f3C. Write the definition of…
A: According to the Question below the Solution: Output:
Q: change.py Create a program, change.py, that has a function that takes 5 arguments that…
A: According to the information given:- We have to follow the instruction to create a program,…
Q: 3.41 Write function lastF() that takes as input two strings of the form 'FirstName' and 'LastName',…
A: def lastF(FirstName,LastName):name="'"name=name+LastNamename=name+","+FirstName[0]+"'"return…
Q: Write a program to read in two consumer price indexes and print out the inflation rate. 1.…
A: The quantitative measure of the rate at which the average price level of a selected goods and…
Q: 4.16 LAB: Toll calculation Toll roads have different fees based on the time of day and on…
A: Program Explanation:- If time is before 7. If the time is after 8 not in the morning. If the time…
Q: In 2022 population of town A is less than population of town B. However, the population of town A…
A: Use a for loop which can iterate for 50 times but we can exit when population of A exceeds…
Q: Q2\A) Write a function that finds the factorial of an integer, the main program calls the function…
A: Factorial of a number n is calculated as the product of numbers from 1 up to n is called the…
Q: 5. A bank charges $10 per month, plus the following check fees for a commercial checking account:…
A: Below i have shown:
Q: 4. Write a function that helps answer questions like ““Today is Wednesday. I leave on holiday in 19…
A: Required:
Q: Exercise 2.1 Write a Program in C++ for a grocery shop payment bill/ receipt. The program should…
A: 2.1 Program: //header files #include<iostream> #include<cstring> #include<conio.h>…
Q: Part 1 Write a program to read in two consumer price indexes and print out the inflation rate.…
A: PROGRAM INTRODUCTION: Include the required header files. Declare the prototype of the function.…
Q: 7. Write a function that receives a floating-point value x and prints the summation of integer…
A: Program Plan: Initialize a variable to store user input, dec. Initialize variables to store the sum…
Q: a. Create a list of 10 numbers. Iterate through the list and store the highest and second highest…
A: Since you have not mentioned the programming language. I will attempt this in python. if you need it…
Q: 17. Write a sub-function “conversion()" based on the program below to convert the time to unit…
A: code snippet:
Q: Q5: Write a complete program that has another function beside the main function. This function…
A: Write a program to calculate radius of a circle using functions complete code of the above program…
Q: 5- Write a group of statements that carry out the same action of upper and lower functions.
A: Your answer to write group of statement that carry same action of upper and lower function is given…
Q: Suppose we have just discovered an alien planet (we will call it Mars), and on this planet one year…
A: C++ program code: #include<iostream>using namespace std;struct charontime{ int days, months,…
Q: 3. An integer n is divisible by 9 if the sum of its digits is divisible by 9. Develop a program to…
A: // C++ program #include <iostream> using namespace std; //takeinput function int…
Q: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats)…
A: Step 1 The code is given in the below step
Q: 7.18 LAB: A jiffy A jiffy" is the scientific name for 1/100th of a second. Define a function named…
A: Algorithm: 1. Take Input. 2. Read the function and return userJiffies/100. 3. Display Output to 3…
Q: C++ Fix the broken code, Fix the function that is being used It does not charge the full hour for…
A: Use round() or ceil() built in function to do round-of double variable value. "cmath" header file…
Q: Part II: Write a program to calculate the area of a triangle given the length of its three sides-a,…
A:
Q: (Time in Seconds) Write a function that takes the time as three integer arguments (forhours,…
A: Lets see the solution.
Q: 17.49 Lab: Functions: Number to words Sometimes numbers are converted to words, like in a…
A: So, we need to write a C++ code to convert numbers into words with the given condition. Program…
Q: Program 3: Write a value-returning function isVowel that returns the value true if a given character…
A: Aim: Write a value returning function isVowel to find if a character is a vowel or not. The program…
Q: Write a function that returns the sum of all the integer numbers dividable by 3 that are smaller…
A: #defined Sum3 function for calculating sum of numbers which are divisible by 3. def Sum3(limit):…
Q: A pedometer treats walking 1 step as walking 2.5 feet. Define a function named feet_to_steps that…
A: # Defining a function def feet_to_steps( user_feet): # Calculating the number of steps…
Q: Create a function called (Ysum) that find the value of y from following equation:
A: In this question, the value of y is to be calculated using this given expression. EXPLANATION:…
Q: def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the…
A: Solution :
Q: Q6 - Write c++ a function named "enough" that takes one integer argument, call it "goal" and returns…
A: #include<iostream>using namespace std;int enough(int goal){if(goal<=0)return 1;int…
Q: 1. Write function printGrade in void function to compute and output the course grade. The course…
A: In This question, I have made some assumptions because you didn't provide the sufficient knowledge…
Q: “Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function.…
A: A date has to be taken from user in the required format. A function that returns how many days we…
Q: 031_Write a C++ simple code to read a student name and grade for two student (Using Structure), then…
A: #include <iostream>using namespace std; struct student{ char name[50]; int roll;…
Q: 5.22 (Separating Digits) Write program segments that accomplish cach of the following: a) Calculate…
A: #include <stdio.h>#include <stdlib.h> int getQuotient(int a, int b) { return a / b;} int…
Q: ++ programming question: Suppose we have just discovered an alien planet (we will call it Mars),…
A: struct { int years, month, days; } charontime;
Q: two points (x1, y1) and (x2, y2). All numbers and return values should be of type double. c++
A: Program : #include <iostream>#include <cmath>using namespace std;float…
Q: 8: PGandE.cpp) Consider a gas and electric bill that sets two levels of use as follows: Gas 10.1…
A: The main object of the program is to read the starting reading gas consumption and ending reading…
Q: 6.19 LAB: Driving costs - functions Write a function driving_cost() with input parameters…
A: Functions: Functions are subprograms that compute a value or perform a task. Functions decrease the…
Q: (Fibonacci Series) The Fibonacci series 0, 1, 1, 2, 3, 5, 8, 13, 21, ... begins with the terms 0 and…
A: // Part a #include <iostream> using namespace std; void fibonacciSeries(int number){ int…
Q: 22.1 LAB: Toll calculations Toll roads have different fees at different times of the day and on…
A: Given: 22.1 LAB: Toll calculations Toll roads have different fees at different times of the…
Q: Problem 2 - Write a function that gets a string argument and capitalizes all the vowels in that…
A: Step-1: Start Step-2: Declare a variable str and take input from user Step-3: Call function…
Q: Assume a function F1 is defined with the heading: int F1(int a, double &b, double t] ); Assume the…
A:
Q: Exercise - Seconds since midnight 1 Let's write a program that reads the time from the user as three…
A: 12 o' clock here is assumed to be the midnight 12 o' clock (12:00 am). 1 minute contains 60 seconds.…
Strugging with a C++ coding problem. Help appreciated.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 8: PGandE.cpp) Consider a gas and electric bill that setstwo levels of use as follows:Gas ElectricTier 1 quantities 10.1 therms 558 kwhTier 1 price $1.415 /therm $.223 /kwhTier 2 Price $1.9)32 /therm $.281 /kwhWrite a program that takes starting and ending readingsfor gas and electric meters and calculates charges to thenearest cent. Use one function to calculate charges for bothgas and electric so as to eliminate duplicate calculations pprogram in c++6.23 LAB - Flip a coin Define a function named CoinFlip that returns "Heads" or "Tails" according to a random value 1 or 0. Assume the value 1 represents "Heads" and 0 represents "Tails". Then, write a main program that reads the desired number of coin flips as an input, calls function CoinFlip() repeatedly according to the number of coin flips, and outputs the results. Assume the input is a value greater than 0. Output the total number of 'Heads' and 'Tails' Hint: Use the modulo operator (%) to limit the random integers to 0 and 1. Ex: If the random seed value is 2 and the input is: 3 the output is: Tails Heads Tails Total Heads: 1 Total Tails: 2 Note: For testing purposes, a pseudo-random number generator with a fixed seed value is used in the program. The program uses a seed value of 2 during development, but when submitted, a different seed value may be used for each test case. The program must define and call the following function:string CoinFlip() Do Not Delete Any Existing…6.23 LAB: Flip a coin Define a function named CoinFlip that returns "Heads" or "Tails" according to a random value 1 or 0. Assume the value 1 represents "Heads" and 0 represents "Tails". Then, write a main program that reads the desired number of coin flips as an input, calls function CoinFlip() repeatedly according to the number of coin flips, and outputs the results. Assume the input is a value greater than 0. Hint: Use the modulo operator (%) to limit the random integers to 0 and 1. Ex: If the random seed value is 2 and the input is: 3 the output is: Tails Heads Tails Note: For testing purposes, a pseudo-random number generator with a fixed seed value is used in the program. The program uses a seed value of 2 during development, but when submitted, a different seed value may be used for each test case. The program must define and call the following function:void CoinFlip(char* decisionString) #include <stdio.h>#include <stdlib.h>#include <string.h> /* Define…
- (Time in Seconds) Write a function that takes the time as three integer arguments (forhours, minutes, and seconds) and returns the number of seconds since the last time the clock “struck12.” Use this function to calculate the amount of time in seconds between two times, both of whichare within one 12-hour cycle of the clock6.use c code to Develop a code that gets two integers from the user and calculates and prints their least common multiplier or LCM. LCM is the smallest number that divides both given integers. Example. lcm (10, 15) = 30, lcm (5,7) = 35 and lcm (12, 24) = 24Hint: we know that lcm(x,y) = xy/gcd(x,y) where gcd is the greatest common divisor (discussed in class). Develop a gcd function in your code, get the two numbers from the user, call your function to calculate their gcd and then use the formula above to calculate and display their lcm GOOD LUCK! Reference This is a list of function prototypes of the C library functions presented in class. You may use any of these functions in your solutions (unless the requirements explicitly indicate otherwise). As you have been provided the function prototypes, you are expected to use the functions correctly in your solutions. double atof(char *string); int atoi(char *string); long atol(char *string); int fclose(FILE *filePointer); char *fgets(char…5.11 LAB: User-Defined Functions: Max and min numbers Coral language only please Define a function named LargestNumber that takes three integers as parameters and returns the largest integer. Define a second function named SmallestNumber that takes three integers as parameters and returns the smallest integer. Then, write a main program that reads three integers as inputs, calls functions LargestNumber() and SmallestNumber() with the inputs as arguments, and outputs the largest and the smallest of the three input values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program should define and call two functions:Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNumFunction SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum
- 22.1 LAB: Toll calculations Toll roads have different fees at different times of the day and on weekends. Write a function CalcToll() that has three arguments: the current hour of time (int), whether the time is morning (bool), and whether the day is a weekend (bool). The function returns the correct toll fee (double), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The function calls below, with the given arguments, will return the following toll fees: CalcToll(8, true, false) returns 2.95CalcToll(1, false, false) returns 1.90CalcToll(3, false, true) returns 2.15CalcToll(5, true, true) returns 1.05 #include <iostream>#include <iomanip>using namespace std; double CalcToll(int hour, bool isMorning, bool isWeekend) { /* Type your code here */} int…C++ The function prototype of a function that recieves two integer values and computes their sum and difference is given as follows: void computeSum (int num1, int num2, int & sum, int & diff); write the statments to call this function to compute and print the sum and the differnce of 167 and 84.6.22 LAB - Swapping variables Define a function named SwapValues that takes four integers as parameters and swaps the first with the second, and the third with the fourth values. Then write a main program that reads four integers from input, calls function SwapValues() to swap the values, and prints the swapped values on a single line separated with spaces. Ex: If the input is: 3 8 2 4 function SwapValues() returns and the main program outputs and SumValues() returns the total of all integers 8 3 4 2 17 The program must define and call these functions:void SwapValues(int& userVal1, int& userVal2, int& userVal3, int& userVal4)Function SwapValues() swaps the values referenced by the parameters.int SumValues(int& userVal1, int& userVal2, int& userVal3, int& userVal4)Function SumValues() sums the values referenced by the parameters. Do Not Delete Any Existing Comments code underneath / where indicated. Any code submitted with comments missing, will…
- 6.26 LAB: Exact change - functions Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is: 0 or less, the output is: no change Ex: If the input is: 45 the output is: 1 quarter 2 dimes Your program must define and call the following function. The function exact_change() should return num_dollars, num_quarters, num_dimes, num_nickels, and num_pennies. def exact_change(user_total) Use Python, please.7. using c++, If c is a character (e.g. char c = ‘a’), then (int) c is a number between 0 and 255 that represents its ascii value of that character (the ascii value of ‘a’ is 97. Appendix B contains the ascii character set; for example, (int) ‘a’ == 97. Write a function that accepts two characters, c1, and c2, determines whether (int) c1 is greater than (int) c2, and then returns the sum of the ascii values of all the characters between c1 and c2.4.16 LAB: Toll calculation Toll roads have different fees based on the time of day and on weekends. Write a function calc_toll() that has three parameters: the current hour of time (int), whether the time is morning (boolean), and whether the day is a weekend (boolean). The function returns the correct toll fee (float), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The function calls below, with the given arguments, will return the following toll fees: calc_toll(8, True, False) returns 2.95calc_toll(1, False, False) returns 1.90calc_toll(3, False, True) returns 2.15calc_toll(5, True, True) returns 1.05