C++ PROGRAM
#include<iostream>
using namespace std;
// implement costOfMeal()
double costOfMeal(double price,int tipPercentag)
{
return price*(tipPercentag/100.0)+price; // return total cost of Meals
}
int main()
{
// declare variables
double price;
int tip;
cout<<"Enter Price: "; cin>>price; // read price
cout<<"Enter Tip: "; cin>>tip; // read tip cost
cout<<costOfMeal(price,tip)<<endl; // calling costOfMeal() function
return 0;
}
OUTPUT-1
Enter Price: 55.5
Enter Tip: 18
65.49
OUTPUT-2
Enter Price: 65.5
Enter Tip: 18
77.29
OUTPUT-3
Enter Price: 95.3
Enter Tip: 20
114.36
Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters....
Using python, write a function that expects two parameters, one will be the amount of the dinner check (a float), and the other one will be the percentage of the tip expressed as an integer(20 for 20 percent). The user will give as input these two values. The function will return to the amount that the tip should be. Output the results.
In Python: Write the definition for a function named avg which accepts two int parameters, and returns the average of the two values Write a statement that calls this function to print out the average of values 11 and 25.
C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa parameter */ //get_letter_grade.cpp /* Write function code for gpa_to_letter_grade that returns a string and accepts a double gpa parameter YOU MUST USE A SWITCH STATEMENT Given a double 3.5 returns the string A TIP: You'll have to convert the double to an int using multiplication Table 3.5 to 4 returns an A 3.0 to 3.49 returns a B 1.7 to 2.99 returns a C...
1. Write code for a function that receives two parameters (a,and b) by value and two more parameters (c and d) by reference. All parameters are double. The function works by assigning c to (a/b) and assigning d to (a*b). The function has no return value. From main, use scanf to get two numbers, then call the function, and then display both outcome values to the output in a printf statement. 2. After part 1 is completed, write code to...
Write a complete program utilizing functions. The function accepts two parameters: one representing a radius of type float, the other parameter is an integer “select” which chooses between finding the area of a circle or the volume of sphere. If the select variable is 1, then area is calculated. If the select value is 2, then volume is calculated. If the select value is any other value, then the function returns 0. Test your function in main by calling it...
c++ write a boolean function that accepts two integer arrays of size 10 as input parameters, the function should return true if there are any similar values between the two arrays and shall return false if not, if there are similar values, print out on screen
Write a program with a function named isEqualArr that accepts a pair of arrays of integers as parameters and returns true if the arrays contain the same elements in the same order. If the arrays are not the same length, your function should return false. For example, if the following arrays are declared: int[] arr1 = {10, 20, 30, 40, 50, 60}; int[] arr2 = {10, 20, 30, 40, 50, 60}; int[] arr3 = {20, 3, 50, 10, 68}; The...
A student has written the following user-defined function to compute the total cost of a dinner for some number of guests. The parameters for this function are the cost per meal (a double) and the number of guests (an integer). There seem to be some errors in the code--what are they? Code written by the student: int dinnerCost ( double mealCost, guests) int total = mealCost * guests; The student failed to declare the datatype of guests as int in...
Function name: triangular Parameters: integer Returns: a list Description: Write a function called triangular that accepts one integer parameter that returns a list with the same number of terms as the value of the parameter. If the parameter is zero or a negative number, you should return an empty list A triangular number is the sum of a positive integer and all the integers before it. The series is as follows: 1, 3, 6, 10, 15, 21,
3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...