0

Duct tape not working

My code for this task is not working in cases 3 and 4, I don't know why. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double height = Convert.ToDouble(Console.ReadLine()); double width = Convert.ToDouble(Console.ReadLine()); double area = (width*height)*2; double tapearea = 60*0.1667; double tapes = (area/tapearea); double tapesfinal = Math.Ceiling(tapes); Console.WriteLine(tapesfinal); } } }

17th Feb 2024, 9:57 AM
Forex X
Forex X - avatar
4 odpowiedzi
0
0.1667 is not the same as 1.0/6.0. Write it as division of the 2 numbers.
17th Feb 2024, 10:54 AM
Lisa
Lisa - avatar
0
Though I am unable to see the Code Coach Pro task, I think that the calculation for tapearea could be more accurate. Is 0.1667 meant to be an approximation of 1/6.0? Maybe 60/6.0 would be better than 60*0.1667, or just plain 10.0.
17th Feb 2024, 10:59 AM
Brian
Brian - avatar
0
Thanks, I thought that rounding the conversion from inches to feet to this value would be enough, but it was not I guess
17th Feb 2024, 11:00 AM
Forex X
Forex X - avatar
0
Forex X , Brian's right. Just change this, double tapearea = 60*0.1667; // 10.002 to this. double tapearea = 10.0; // 10.0 A roll of tape 60 feet long and 2 inches wide (said the description before pro) has 10 square feet of total area. Yeah, it does seem weird that the 0.002 square feet difference would make a difference, since you round up to the next roll anyway, but there must be a test case at or near the transition point, where it matters.
17th Feb 2024, 11:23 PM
Rain
Rain - avatar