Canadian Computing Competition: 2005 Stage 1, Junior #1
Moe Bull has a cell phone and after a month of use is trying to decide which price plan is the best for his usage pattern. He has two options, each plan has different costs for daytime minutes, evening minutes and weekend minutes.
Plan | Costs | ||
---|---|---|---|
daytime | evening | weekend | |
A | 100 free minutes then 25 cents per minute | 15 cents per minute | 20 cents per minute |
B | 250 free minutes then 45 cents per minute | 35 cents per minute | 25 cents per minute |
Write a program that will input the number of each type of minutes and output the cheapest plan for this usage pattern, using the format shown below. The input will be in the order of daytime minutes, evening minutes and weekend minutes. In the case that the two plans are the same price, output both plans.
Sample Input 1
251
10
60
Sample Output 1
Plan A costs 51.25
Plan B costs 18.95
Plan B is cheapest.
Sample Input 2
162
61
66
Sample Output 2
Plan A costs 37.85
Plan B costs 37.85
Plan A and B are the same price.
CCC problem statements in large part from the PEG OJ
Comments
where is wrong with my code...
Since the original data were weak, an additional test case was added, and all
Accepted
submissions were rejudged.the problem doesn't state to round to 2 decimal points even though the new test case does. And even the sample outputs don't have a test case where it ends with #.#0 or #.00
Can Anyone tell me what is wrong with my code, because apparently I only passed the first test case. https://dmoj.ca/submission/4220817
You have to round to two decimal places.
it says my output is clipped even though its correct because it says plan A is the cheapest and plan a is 2.65 and plan B is 4.45.
Someone please help me.
It’s because you typed in the wrong number in the if elif maybe?cause I had the same problem
"Clipped output" means that we are only displaying some prefix of your output; it does not take much imagination to see what problems showing the entirety of a submission's output could cause.
Additionally, I find your claim that your output is correct to be false: reread the samples carefully.
Could someone help me with my code? I am starting C# from python and I am puzzled as to why I am correct for the second test but not the first or third? Any help would be greatly appreciated! :)
A problem I had when writing the code was allowing the daytime cost to be less than zero. Since it = daytime minutes - 100 or 250 * the cost per minute, if the daytime minutes are less than 100 or 250 that term will become negative.
The problem I had was that I wasn't outputting only two decimal places, one of the tests is to input all three variables as 0 and if you don't output 0.00 for the first two outputs, you won't even get a single mark, If you think this is the problem for you and you are using Java use this link,
https://www.java67.com/2014/06/how-to-format-float-or-double-number-java-example.html#:~:text=format(%22%25.,float%20data%20type%20in%20Java.
if you aren't using java search up number formats for two decimal places for your language, this simple fix got me from 0 points from all tests to 100%.
Remember: for each of the plans, it's some_value cents/minute. The output prices for each of the plans should be in dollars :)
Spent 20 mins debugging because the output is worded "Plan B is cheapest." vs "Plan B is the cheapest." which is proper grammar.
This comment is hidden due to too much negative feedback. Show it anyway.
Only 20 min? Good job, that would have taken me hours.
same
Are compile errors due to bad code? Because my code works on my laptop but I get a compile error when submitting. The same thing happened for another problem but I resubmitted and it worked but that's not fixing the error here.
EDIT: I fixed it by using Math.round() instead of DecimalFormat, but I don't see why DecimalFormat shouldn't work (Java 8)
You may want to import
java.text.DecimalFormat
.I don't get why my first case is wrong. They are the same price, aren't they?
Your program prints
Plan A and Plan B are the same price.
when the plans cost the same amount.This comment is hidden due to too much negative feedback. Show it anyway.
"Plan A is cheap"
"Plan A is cheaper"
...
Both are correct; cheapest is an adjective but it's a superlative so you can also stick a definitive article (i.e. "the") in front of it and treat is as though it were a noun.
How correct the grammar is doesn't matter; it's simply the output specifications.
Plan A costs 37.85 Plan B costs 37.849999999999994 Plan B is cheapest.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.