C
C#9mo ago
BabySid

❔ I need help with this Question?

No description
94 Replies
mtreit
mtreit9mo ago
Which part are you struggling with?
BabySid
BabySid9mo ago
the starting
mtreit
mtreit9mo ago
Show what code you have written so far
BabySid
BabySid9mo ago
I haven't started yet
mtreit
mtreit9mo ago
I would suggest giving it a try and if you have specific questions on code you can't get working you can ask here. We aren't going to write it for you.
Pobiega
Pobiega9mo ago
Then you need to start. The task is fairly well described already Start with taking the required inputs and work from there
WEIRD FLEX
WEIRD FLEX9mo ago
more donuts -> less money
GaSkia
GaSkia9mo ago
u solved?
Isaaaak
Isaaaak9mo ago
I solved it (I know it was easy, but I'm a beginner so)
BabySid
BabySid9mo ago
I did something I ain't sure if its correct
Isaaaak
Isaaaak9mo ago
Post it
BabySid
BabySid9mo ago
using System; class Program { static void Main() { const double costPerDonut1to4 = 2.00; const double costPerDonut5to9 = 1.75; const double costPerDonut10OrMore = 1.50; const double costPerDonut12OrMore = 1.00; const double hstRate = 0.13; const double coverCharge = 0.25; Console.Write("Enter your last name: "); string lastName = Console.ReadLine(); Console.Write("Enter the number of donuts you want to purchase: "); int donutsPurchased = int.Parse(Console.ReadLine()); double totalCost = 0; if (donutsPurchased <= 4) { totalCost = donutsPurchased * costPerDonut1to4; } else if (donutsPurchased < 10) { totalCost = donutsPurchased * costPerDonut5to9; } else { totalCost = donutsPurchased * costPerDonut10OrMore; } // Check if the customer is eligible for HST exemption if (donutsPurchased < 12) { totalCost += totalCost * hstRate; } totalCost += coverCharge; Console.WriteLine($"Total cost: ${totalCost:F2}"); } } what bout this
mtreit
mtreit9mo ago
Tip: use $code to post code in a more readable way
MODiX
MODiX9mo ago
Posting Code Snippets To post a code snippet type the following: ```cs // code here ``` Notes: - Get an example by typing $codegif in the chat. - Change the language by replacing cs with the language of your choice (for example sql or cpp). - If your code is too long, you can post it to https://paste.mod.gg/ and share the link.
BabySid
BabySid9mo ago
```c# using System; class Program { static void Main() { const double costPerDonut1to4 = 2.00; const double costPerDonut5to9 = 1.75; const double costPerDonut10OrMore = 1.50; const double costPerDonut12OrMore = 1.00; const double hstRate = 0.13; const double coverCharge = 0.25; Console.Write("Enter your last name: "); string lastName = Console.ReadLine(); Console.Write("Enter the number of donuts you want to purchase: "); int donutsPurchased = int.Parse(Console.ReadLine()); double totalCost = 0; if (donutsPurchased <= 4) { totalCost = donutsPurchased * costPerDonut1to4; } else if (donutsPurchased < 10) { totalCost = donutsPurchased * costPerDonut5to9; } else { totalCost = donutsPurchased * costPerDonut10OrMore; } // Check if the customer is eligible for HST exemption if (donutsPurchased < 12) { totalCost += totalCost * hstRate; } totalCost += coverCharge; Console.WriteLine($"Total cost: ${totalCost:F2}"); } }
SinFluxx
SinFluxx9mo ago
cs not c#, and you need the 3x ` at the end too
BabySid
BabySid9mo ago
BlazeBin
A tool for sharing your source code with the world!
SinFluxx
SinFluxx9mo ago
$codegif
BabySid
BabySid9mo ago
here
Isaaaak
Isaaaak9mo ago
Looks pretty good, but there are some errors in how you calculate the total cost. Maybe try calculating it manually (with a calculator) for 15 donuts using the original table and see if it matches up, and if it doesn't, why?
No description
mtreit
mtreit9mo ago
@BabySid that looks like a pretty good first attempt but I'm not sure you quite followed this table:
No description
BabySid
BabySid9mo ago
using System;

class Program
{
static void Main()
{
const double costPerDonut1to4 = 2.00;
const double costPerDonut5to9 = 1.75;
const double costPerDonut10OrMore = 1.50;
const double costPerDonut12OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0;

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

// Check if the customer is eligible for HST exemption
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
using System;

class Program
{
static void Main()
{
const double costPerDonut1to4 = 2.00;
const double costPerDonut5to9 = 1.75;
const double costPerDonut10OrMore = 1.50;
const double costPerDonut12OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0;

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

// Check if the customer is eligible for HST exemption
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
cs
Isaaaak
Isaaaak9mo ago
hah I was first :P
mtreit
mtreit9mo ago
🥷
BabySid
BabySid9mo ago
I didn't understand it properly could you explain it once more please?
Isaaaak
Isaaaak9mo ago
Oooh wait maybe I've misunderstood this slightly Is this pricing $ for the total donuts or does the pricing only apply to the donuts above that level? Like say I buy 15 donuts, does that mean it's 15*$1 = $15 or is it more than that because the earlier donuts are more expensive?
mtreit
mtreit9mo ago
It should be the former Based on how I read the assignment
BabySid
BabySid9mo ago
yes its $15 plus cover charge
Isaaaak
Isaaaak9mo ago
I thought so too, at first. But maybe not? idk
mtreit
mtreit9mo ago
No description
BabySid
BabySid9mo ago
oh shi- hold on I see it
SinFluxx
SinFluxx9mo ago
A single donut is also its own price, not 1-4 as a bracket
BabySid
BabySid9mo ago
so 1 donut is 2 dollars 2donuts to 4 donuts is 1.75 dollars 5 donuts to 9 donuts is 1.50 dollars 10 donuts onwards its 1 dollar right?
Isaaaak
Isaaaak9mo ago
yeah but
BabySid
BabySid9mo ago
shi-
Isaaaak
Isaaaak9mo ago
I'm still not sure if it's like each donut has it's own price or if all the donuts cost $1 if i buy 10 donuts Like either all cost $1 each = $10 or 1st donut cost $2, second to fourth donut $1.75 etc. leading to a higher sum
SinFluxx
SinFluxx9mo ago
I'd assume the simpler pricing from the wording, it's not income tax!
Isaaaak
Isaaaak9mo ago
it's a bit ambigous
mtreit
mtreit9mo ago
The table is pretty clear
Isaaaak
Isaaaak9mo ago
but the problem is then it's much more expensive to buy 9 donuts than 10 lol buy 12 donuts for the same price as 9? xD doesn't make much sense from a business perspective anyways, too much logic for a simple problem
SinFluxx
SinFluxx9mo ago
🤷 I don't think it's meant to represent a legitimate business
BabySid
BabySid9mo ago
uhgg I need to fix this now lol
mtreit
mtreit9mo ago
I would use pattern matching I think to have a nice clean way of expressing the cost-per-donut calculation but for a beginner problem that's probably not a good idea.
BabySid
BabySid9mo ago
ummmm
Isaaaak
Isaaaak9mo ago
const double costPerDonut1to4 = 2.00; // Is this correct? I think in the table it says if you buy 1 donut it is $2, but if you buy 2 to 4 donuts it's $1.75 per donut
const double costPerDonut5to9 = 1.75; // I think the table says 5 to 9 donuts is $1.50
const double costPerDonut10OrMore = 1.50; // Same here, should be $1.00
const double costPerDonut12OrMore = 1.00; // Unnecessary, isn't used
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0; // you could add the cover charge here already

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

// Check if the customer is eligible for HST exemption
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");

// you need to add a check to see if donutsPurchased is atleast 1, if it isn't the program should exit immediatly (because you can't order less than 1 donut)
const double costPerDonut1to4 = 2.00; // Is this correct? I think in the table it says if you buy 1 donut it is $2, but if you buy 2 to 4 donuts it's $1.75 per donut
const double costPerDonut5to9 = 1.75; // I think the table says 5 to 9 donuts is $1.50
const double costPerDonut10OrMore = 1.50; // Same here, should be $1.00
const double costPerDonut12OrMore = 1.00; // Unnecessary, isn't used
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0; // you could add the cover charge here already

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

// Check if the customer is eligible for HST exemption
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");

// you need to add a check to see if donutsPurchased is atleast 1, if it isn't the program should exit immediatly (because you can't order less than 1 donut)
added some comments
SinFluxx
SinFluxx9mo ago
Why does the hstRate calculation need changing?
Isaaaak
Isaaaak9mo ago
oh shit nvm it doesn't wow I'm stupid it's just another way of doing it
SinFluxx
SinFluxx9mo ago
The only other thing is just to check you're outputting all the required information at the end blobthumbsup
BabySid
BabySid9mo ago
wow okay lemem give this a whirl
Isaaaak
Isaaaak9mo ago
Also maybe consider which data type should be used when money is involved
SinFluxx
SinFluxx9mo ago
And as @Isaaaak pointed out that you can add the cover charge earlier, especially as the instructions say the cover charge is pre hst
BabySid
BabySid9mo ago
oh okay so I check for hst after adding the covercharge?
Isaaaak
Isaaaak9mo ago
yep
SinFluxx
SinFluxx9mo ago
Yeah 🙂
BabySid
BabySid9mo ago
hmmm okay thank you so much
Isaaaak
Isaaaak9mo ago
because the cover charge is also taxed
BabySid
BabySid9mo ago
I'll brb oh
using System;

class Program
{
static void Main()
{
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0;

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
using System;

class Program
{
static void Main()
{
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

double totalCost = 0;

if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}
if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
cs how about now its working the subtotal is correct
Isaaaak
Isaaaak9mo ago
1. What happens if a customer orders 1 donut? In the table it says 1 donut should cost $2 2. What happens if the customers says they want 0 or a negative amount of donuts? What should happen? (what does the original question say?) 3. Which datatype should be used when we are talking about money in C#? Is double correct or is there a better one? 4. Are you outputting everything the original question says you should output? 5. Is the last "else"-statement necessary?
BabySid
BabySid9mo ago
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
cs I fixed for the 0 or negative one first one as well
BabySid
BabySid9mo ago
Also how would I output this ?
No description
Isaaaak
Isaaaak9mo ago
Same as you outputted cost, just copy that two more times and change the text + variable (in the right order ofc) very nice, works good
BabySid
BabySid9mo ago
wait I didn't comprehend this
Isaaaak
Isaaaak9mo ago
Console.WriteLine($"Total cost: ${totalCost:F2}"); Copy this, but change it slightly so you get the right text and the right variable
mtreit
mtreit9mo ago
There is a crashing bug in that code.
BabySid
BabySid9mo ago
aha gotcha wait wha?
Isaaaak
Isaaaak9mo ago
You have two "if"-statements here. What problems could arise? Do you get the correct total cost if you order 1 donut?
No description
mtreit
mtreit9mo ago
See what happens when the user types "three" instead of "3"
Isaaaak
Isaaaak9mo ago
I don't think there are any requirements that the user should be able to input anything else other than integers?
mtreit
mtreit9mo ago
Users never follow the rules 😉 Although I think the instructions did say you can assume it will be a valid integer. But in other contexts you would want to think about this kind of thing.
Isaaaak
Isaaaak9mo ago
Yep, error-handling is important
BabySid
BabySid9mo ago
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine("Last Name: " + lastName);
Console.WriteLine("Number of Donuts Purchased: " + donutsPurchased);
Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine("Last Name: " + lastName);
Console.WriteLine("Number of Donuts Purchased: " + donutsPurchased);
Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
cs it displays this as well now 😭
mtreit
mtreit9mo ago
if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
Thonk step through that mentally and see what happens...
BabySid
BabySid9mo ago
holy hsit I'm dumb asf
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
else if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine("Last Name: " + lastName);
Console.WriteLine("Number of Donuts Purchased: " + donutsPurchased);
Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
using System;

class Program
{
static void Main()
{
const double costPerDonut1 = 2.00;
const double costPerDonut1to4 = 1.75;
const double costPerDonut5to9 = 1.50;
const double costPerDonut10OrMore = 1.00;
const double hstRate = 0.13;
const double coverCharge = 0.25;

Console.Write("Enter your last name: ");
string lastName = Console.ReadLine();

Console.Write("Enter the number of donuts you want to purchase: ");
int donutsPurchased = int.Parse(Console.ReadLine());

if (donutsPurchased <= 0)
{
Console.WriteLine("Error: You must order at least one donut.");
}
else
{
double totalCost = 0;

if (donutsPurchased == 1)
{
totalCost = donutsPurchased * costPerDonut1;
}
else if (donutsPurchased <= 4)
{
totalCost = donutsPurchased * costPerDonut1to4;
}
else if (donutsPurchased < 10)
{
totalCost = donutsPurchased * costPerDonut5to9;
}
else
{
totalCost = donutsPurchased * costPerDonut10OrMore;
}

if (donutsPurchased < 12)
{
totalCost += totalCost * hstRate;
}
else
{
totalCost = totalCost;
}

totalCost += coverCharge;

Console.WriteLine("Last Name: " + lastName);
Console.WriteLine("Number of Donuts Purchased: " + donutsPurchased);
Console.WriteLine($"Total cost: ${totalCost:F2}");
}
}
}
cs apologies
mtreit
mtreit9mo ago
Turn on "warnings as errors" when
Isaaaak
Isaaaak9mo ago
no worries ofc
BabySid
BabySid9mo ago
ya'll are life savers thank you so blushowo
Isaaaak
Isaaaak9mo ago
1. What happens if a customer orders 1 donut? In the table it says 1 donut should cost $2. What should the total sum be when a customer buys 1 donut (calculate manually and compare to what your program says)? If they don't add up, why? wait nvm you fixed this one^^ 2. Which data type should be used when we are talking about money in C#? Is double correct or is there a better one? 3. Is the last "else"-statement necessary?
BabySid
BabySid9mo ago
the first one I've calculated I guess for the second one we've been taught double only third one 😁
Isaaaak
Isaaaak9mo ago
ooh wait I've found something If we calculate 1 donut manually we get (2+0.25)*1.13 = $2,54 but the program says $2.51 How come?
BabySid
BabySid9mo ago
I'll check just a sec
Isaaaak
Isaaaak9mo ago
I'll give you a hint if you don't figure it out
BabySid
BabySid9mo ago
I discovered something else as well I still can't see this can you figure out why 😢
Isaaaak
Isaaaak9mo ago
I think it looks good?
No description
BabySid
BabySid9mo ago
hold on but when I input 0 or any negative number it doesn't show the following for rest of em it shows the following
Isaaaak
Isaaaak9mo ago
For me it does
No description
Isaaaak
Isaaaak9mo ago
Maybe you have it so your console instantly closes when the program ends? If so, you can just add an empty Console.ReadLine(); under the error statement
Isaaaak
Isaaaak9mo ago
No description
mtreit
mtreit9mo ago
You should put something like:
Console.WriteLine("Press <Enter> to exit the program.");
Console.WriteLine("Press <Enter> to exit the program.");
so the user isn't left staring at the screen wondering why the program doesn't finish.
BabySid
BabySid9mo ago
oh yeh I fixed it thank you so much
Isaaaak
Isaaaak9mo ago
still wrong total cost though hmmhm
BabySid
BabySid9mo ago
nono
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Best duplex communication protocolHi! What do you guys think that will be the best way to have communication between 2 apps (one in .n❔ rendering windows forms over another windowhello : ) my goal is to make a checklist application that can be rendered over other windows so you ✅ my mouse doesn’t workLast night I was playing a game and the game was fine next afternoon I boot my pc and I can’t move m✅ I have 5 errors and have 0 ideas on how to fix them :(Ok so i havve syntax error, '(' expected at line 31 i havev ) expected at line 31 i havve ; expected✅ gaps in database keysI don't know if this is the best place to post it as it is more related to databases. However. I am❔ ✅ C# program can't find folder in the very same directoryMy program works fine but when I instead run the main program's functionality from a test-project th❔ I made a function to check that there is no Same last variable in two queues in the queue arrayCan you please check if I made it right, because I had to assign last and secondlast in order for itI'm having trouble understanding Bubble Sort.So the whole schtick about a bubble algorithm is that it compares a number with the number next to i✅ PaintEventArgs and GraphicsI have the answers to a question yet i dont get how they can write `gr = pea.Graphics;` when i try iMy WPF Application instance implements a custom interface, but second DLL doesn't see the interfaceI have an application written in WPF where one of the assemblies needs an `System.Net.Http.HttpClien