How many different final sums satisfy the conditions

Assignment Help Computer Engineering
Reference no: EM132105172

Problem Statement

In a restaurant, if you were pleased by the waiter's service, you may leave him a tip -- you pay him more than the actual value of the bill, and the waiter keeps the excess money. In some countries, not leaving a tip for the waiter is even considered impolite. During my recent holiday I was having dinner in a foreign restaurant. The pamphlet from my travel agency informed me that the proper way of tipping the waiter is the following:

The sum I pay must be round, i.e., divisible by 5.

The tip must be between 5% and 10% of the final sum I pay, inclusive.

Clearly, sometimes there may be multiple "correct" ways of settling the bill. I'd like to know exactly how many choices I have in a given situation. I could program it easily, but I was having a holiday... and so it's you who has to solve this task. You will be given:

an int bill -- the amount I have to pay for the dinner

an int cash -- the amount of money I have in my pocket

Write a function that computes how many different final sums satisfy the conditions above.

Constraints

Assume that both bill and cash are in dollars.

All the money I have is in one-dollar banknotes.

My Code:

int possible_payments(int bill, int cash) {
// fill in code here
int choices;
int counter = 0;
int leftoverCash = cash - bill;
int i = 0;

for (i; i < leftoverCash; i++){
int tipPercent = (i/bill)*100;
int total = i + bill;
if((total % 5 == 0) && (tipPercent <= 10) && (tipPercent >= 5)){
counter++;
}
}

return choices;
}

Reference no: EM132105172

Questions Cloud

Broken up into three sub-accounts : Since the inventory costs of a manufacturing firm are broken up into three sub-accounts
Benefits and challenges of virtual teams : What are the potential benefits and challenges of virtual teams and it will impact a project?
Managed for a team composed of members : How can Virtual Teams be managed for a team composed of members who are all co-located in project management?
Discuss the differences between the terms product scope : Discuss the differences between the terms "product scope" and "project scope" and explain how scope
How many different final sums satisfy the conditions : Write a function that computes how many different final sums satisfy the conditions .
Monitor the health of the project : What are some key components to monitor the health of the project, as it relates to earned value?
Wbs for an it project : Newly appointed project manager in my company asked me to review his WBS for an IT project. The thirty-day project had 340 work packages
Demonstrate application of business strategy : Demonstrate application of Business Strategy - External analysis - You may incorporate strategical tools from the buttom - Write a report on one nominated case
What are five problems within the case study : What are five problems within the case study? Does the creation of a MIS group solve any problems? Why or why not?

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is mno

What is MNO.

  Design an eight-bit shift register using jk flip-flops

Design an eight-bit shift register using 74109 JK flip-flops. Parallel and serial input, serial output, and right-shift features are required.

  Define ways in which the organization impacted

Provide the name, website URL, and a background of the organization (at least 5 sentences). Three (3) ways in which the organization impacted?

  Define a formal information systems security plan

Effective information security recommendations must be incorporated into a formal information systems security plan

  Define computers with a huge number of neuron circuits

If the brain is a computer and the mind its workings, is this a fitting analogy of computer and its software? What would happen if we had dedicated computers with a huge number of neuron circuits? Would intelligence develop? Would we be able to un..

  Demonstrate the functionality of all elements of assignment

Demonstrate the functionality of all elements of this assignment. As you go, take instructional notes and screen shots that will help to reproduce your process.

  Describes the problem being address

Complete a problem analysis that describes the problem being address, and the benefit this system will have for the coaches and administration of the college. When you make a claim in the opening section be sure to follow up or prove it in the bod..

  Show how to connect given ttl to right circulate the input

TTL 74194 is a 4-bit universal shift register. Show how to connect TTL 74194 to left shift the input discarding the leftmost bit and setting the rightmost bit.

  Write a function that will take a vector of int values

Write a function that will take a vector of int values as argument and it will return the pairs of values in that vector that sum to 0.

  Describe scenario where employee compromise security policy

Describe a scenario where an employee might compromise a security policy in order to perform a particular job function.

  What is the index type of the array variable rainbow

What is the index type of the array variable Count? What is the index type of the array variable Rainbow? How many components are there in array variable Count?

  What does the start-up o code do for your microcontroller

How many bits does your compiler allocate for char int, and long data types?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd