Suppose you went to a coffee shop and you want to drink some coffee. You decided to drink n cup of coffee, where n is an integer value greater than 0. Now you have to pay m taka for the first cup of coffee, 2m taka for the second cup, 3m takas for the third cup, and so on. In other words, you have to pay i*m taka for the i-th cup of coffee. Now you have k taka in your pocket. How many takas do you need to borrow from your friend to buy n cup of coffee? The first input in the sample input contains the cost of the first cup of coffee which can be denoted as m. The second input is the number of coffees you want to drink, n. The third input is k, the initial amount of taka you have. You have to calculate how much money you have to borrow from your friend. If you have more or equal amount of money that is needed than print 0. Sample Input 1: 3 5 15 Sample Output 1: 30 Explanation 1: Here the price of the first cup of coffee is 3 taka and you want to drink 5 cups of coffee. So you will need a total of 3 + 6 + 9 + 12 + 15 = 45 tk. But you have 15 tk in your pocket. So you have to borrow 45 - 15 = 30 taka from your friend.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please post screenshot of the code and use commands for better understanding thank you .

tlon.
Suppose you went to a coffee shop and you want to drink some coffee. You decided to drink
n cup of coffee, where n is an integer value greater than 0. Now you have to pay m taka for
the first cup of coffee, 2m taka for the second cup, 3m takas for the third cup, and so on. In
other words, you have to pay i*m taka for the i-th cup of coffee.
Now you have k taka in your pocket. How many takas do you need to borrow from your
friend to buy n cup of coffee?
The first input in the sample input contains the cost of the first cup of coffee which can be
denoted as m. The second input is the number of coffees you want to drink, n. The third
input is k, the initial amount of taka you have. You have to calculate how much money you
have to borrow from your friend. If you have more or equal amount of money that is needed
than print 0.
Sample Input 1:
3
15
Sample Output 1:
30
Explanation 1:
Here the price of the first cup of coffee is 3 taka and you want to drink 5 cups of coffee. So
you will need a total of 3 + 6 + 9 + 12 + 15 = 45 tk. But you have 15 tk in your pocket. So you
have to borrow 45 - 15 = 30 taka from your friend.
Sample Input 2:
100
4
1010
Transcribed Image Text:tlon. Suppose you went to a coffee shop and you want to drink some coffee. You decided to drink n cup of coffee, where n is an integer value greater than 0. Now you have to pay m taka for the first cup of coffee, 2m taka for the second cup, 3m takas for the third cup, and so on. In other words, you have to pay i*m taka for the i-th cup of coffee. Now you have k taka in your pocket. How many takas do you need to borrow from your friend to buy n cup of coffee? The first input in the sample input contains the cost of the first cup of coffee which can be denoted as m. The second input is the number of coffees you want to drink, n. The third input is k, the initial amount of taka you have. You have to calculate how much money you have to borrow from your friend. If you have more or equal amount of money that is needed than print 0. Sample Input 1: 3 15 Sample Output 1: 30 Explanation 1: Here the price of the first cup of coffee is 3 taka and you want to drink 5 cups of coffee. So you will need a total of 3 + 6 + 9 + 12 + 15 = 45 tk. But you have 15 tk in your pocket. So you have to borrow 45 - 15 = 30 taka from your friend. Sample Input 2: 100 4 1010
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY