Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A) Write a function named avg3 that accepts three numbers and returns their average. Example: avg3(4, 2, 6) => 4 avg3(3.14159, 2.71, 2.23) => 2.69653

A) Write a function named avg3 that accepts three numbers and returns their average.

Example: avg3(4, 2, 6) => 4 avg3(3.14159, 2.71, 2.23) => 2.69653

B) Write a function named computeTip that accepts two numbers (the cost of a meal or other service, and the tip percentage) and returns a number representing the tip.

Example: computeTip(10.00, 0.15) => 1.5 When this is working, modify the function to return a string, representing the tip in currency format

Example: getTip(10, 0.2) => "$2.00"

C) Write a function pizzaPSI that accepts two numbers (the cost of a pizza and the diameter in inches) and returns the cost Per Square Inch, in currency format.

Example: pizzaPSI(10.00, 12) => $0.09 pizzaPSI(23.95, 18) => $0.09

E) Write a function named sumNumbers that accepts a nonnegative number, adds up all of the numbers between 0 and the number (inclusive), and returns the sum. Use a while loop to solve this problem.

Example: sumNumbers(3) => 6 sumNumbers(6) => 21 sumNumbers(0) => 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions