C# using MindTap How do I round this up to 2 decimals: I need the total...

60.1K

Verified Solution

Question

Programming

C# using MindTap How do I round this up to 2 decimals: I needthe total to round to two decimals example instead of the output tobe 119.625 it needs to be 119.63

using System;
using static System.Console;
using System.Globalization;
class DemoJobs
{
static void Main()
{
Job job1 = new Job();
Job job2 = new Job();
Job job3 = new Job();
job1.Description = \"wash windows\";
job1.Time = 3.5;
job1.Hourly = 25.00;
job2.Description = \"clean garden\";
job2.Time = 2;
job2.Hourly = 18.50;
job3 = job1 + job2;
Display(job1);
Display(job2);
Display(job3);
}
internal static void Display(Job j)
{
WriteLine(\"Job : {0} is {1} per hour for {2} hours.\n Total = {3}\",j.Description, j.Hourly.ToString(\"C\",CultureInfo.GetCultureInfo(\"en-US\")), j.Time, j.Total.ToString(\"C\",CultureInfo.GetCultureInfo(\"en-US\")));
}
}

class Job
{
private string description;
private double time;
private double hourly;
private double total;
public string Description
{
get
{
return description;
}
set
       {
description = value;
}
}
public double Time
{
get
{
return time;
}
set
{
time = value;
CalcTotal();
}
}
public double Hourly
{
get
{
return hourly;
}
set
{
hourly = value;
CalcTotal();
}
}

public double Total
{
get
{
       return total;
}
}

private void CalcTotal()
{
total = Time * Hourly;
}

public static Job operator +(Job j1,
Job j2)
{
Job temp = new Job();
temp.Description = j1.Description + \" and \" + j2.Description;
temp.Time = j1.Time + j2.Time;
temp.Hourly = (j1.Hourly + j2.Hourly) / 2;
return temp;
}
}

Answer & Explanation Solved by verified expert
4.0 Ratings (482 Votes)
You can use MathRounddoublevaluen where nno of digits using System using static SystemConsole class DemoJobs static void Main Job job1 new Job Job job2 new Job Job job3 new Job job1Description wash windows    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students