Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need done Monday night 3/8/21! thank you in advance In C programming: Given a list of individuals, how much they spent, and a value ratio

Need done Monday night 3/8/21! thank you in advance

In C programming: Given a list of individuals, how much they spent, and a value ratio for the currency, sort the individuals from greatest to least in terms of paid value. Input will begin with a line containing 1 integer, n, representing the number of paying customers. The following n lines will each contain a description of a customer. The i-th of which contains a single name followed by two space separated non-negative integers, t and b, representing the number of tokens and the number of bills the i-th person paid respectively. The last line of input will contain 2 integers a and b, which represent the exchange rate between the two currencies "a tokens is worth b bills." Each name will have at least one character and at most 20 characters, and will not contain whitespace characters. Avoid using ints to prevent overflow, use long long ints to allow for 64 bits of precision. Try to store the people into a struct that stores their units, name, etc. Please use a merge or quick sort. Sample input: 5 John 3 10 Jacob 7 7 Rob 5 8 Nancy 4 5 Phil 11 4 10 13 Sample output: Phil Jacob Rob John Nancy Explanation: 10 tokens are worth 13 bills. We can say that each token is worth 13 units and each bill is worth 10 units. We find out how many units each person has: John has 3 tokens and 10 bills which equates to 3 * 13 + 10 * 10 units = 139 units. Jacob has 7 tokens and 7 bills which equates to 7 * 13 + 7 * 10 units = 161 units. Rob has 5 tokens and 8 bills which equates to 5 * 13 + 8 * 10 units = 145 units. Nancy has 3 tokens and 10 bills which equates to 4 * 13 + 5 * 10 units = 102 units. Phil has 3 tokens and 10 bills which equates to 11 * 13 + 4 * 10 units = 183 units.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago