0
Paint costs C# one test fail
I have code: int colors = Convert.ToInt32(Console.ReadLine()); double dcost = 40.00 + (colors * 5.00)+((40.00 + (colors * 5.00))*0.10); Console.WriteLine(dcost); dcost = Math.Round(dcost); Console.WriteLine(dcost); Before and used only int and tax as double and next Convert.ToInt32 and have the same problem int colors = Convert.ToInt32(Console.ReadLine()); int costs = 40 + (colors * 5); double tax = costs * 0.10; int t = Convert.ToInt32(tax); int totalCost = costs + t; Console.WriteLine(totalCost); I check few numbers and rounding seems to work well :/
2 Respuestas
+ 6
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 total_cost;
double cost,tax;
int numberOfcolor = int.Parse(Console.ReadLine());
cost=(numberOfcolor*5)+40;
tax=cost/10;
total_cost=Math.Ceiling(tax)+cost;
Console.WriteLine(total_cost);
}
}
}
0
Oh okey i changed Math.Round on Math.Ceiling and everything is pass, thanks