C
C#14mo ago
BabySid

❔ I need help with this Question?

No description
94 Replies
mtreit
mtreit14mo ago
Which part are you struggling with?
BabySid
BabySidOP14mo ago
the starting
mtreit
mtreit14mo ago
Show what code you have written so far
BabySid
BabySidOP14mo ago
I haven't started yet
mtreit
mtreit14mo 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
Pobiega14mo ago
Then you need to start. The task is fairly well described already Start with taking the required inputs and work from there
Omnissiah
Omnissiah14mo ago
more donuts -> less money
GaSkia
GaSkia14mo ago
u solved?
Isaaaak
Isaaaak14mo ago
I solved it (I know it was easy, but I'm a beginner so)
BabySid
BabySidOP14mo ago
I did something I ain't sure if its correct
Isaaaak
Isaaaak14mo ago
Post it
BabySid
BabySidOP14mo 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
mtreit14mo ago
Tip: use $code to post code in a more readable way
MODiX
MODiX14mo 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
BabySidOP14mo 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
SinFluxx14mo ago
cs not c#, and you need the 3x ` at the end too
BabySid
BabySidOP14mo ago
BlazeBin
A tool for sharing your source code with the world!
SinFluxx
SinFluxx14mo ago
$codegif
BabySid
BabySidOP14mo ago
here
Isaaaak
Isaaaak14mo 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
mtreit14mo ago
@BabySid that looks like a pretty good first attempt but I'm not sure you quite followed this table:
No description
BabySid
BabySidOP14mo 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
Isaaaak14mo ago
hah I was first :P
mtreit
mtreit14mo ago
🥷
BabySid
BabySidOP14mo ago
I didn't understand it properly could you explain it once more please?
Isaaaak
Isaaaak14mo 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
mtreit14mo ago
It should be the former Based on how I read the assignment
BabySid
BabySidOP14mo ago
yes its $15 plus cover charge
Isaaaak
Isaaaak14mo ago
I thought so too, at first. But maybe not? idk
mtreit
mtreit14mo ago
No description
BabySid
BabySidOP14mo ago
oh shi- hold on I see it
SinFluxx
SinFluxx14mo ago
A single donut is also its own price, not 1-4 as a bracket
BabySid
BabySidOP14mo 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
Isaaaak14mo ago
yeah but
BabySid
BabySidOP14mo ago
shi-
Isaaaak
Isaaaak14mo 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
SinFluxx14mo ago
I'd assume the simpler pricing from the wording, it's not income tax!
Isaaaak
Isaaaak14mo ago
it's a bit ambigous
mtreit
mtreit14mo ago
The table is pretty clear
Isaaaak
Isaaaak14mo 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
SinFluxx14mo ago
🤷 I don't think it's meant to represent a legitimate business
BabySid
BabySidOP14mo ago
uhgg I need to fix this now lol
mtreit
mtreit14mo 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
BabySidOP14mo ago
ummmm
Isaaaak
Isaaaak14mo 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
SinFluxx14mo ago
Why does the hstRate calculation need changing?
Isaaaak
Isaaaak14mo ago
oh shit nvm it doesn't wow I'm stupid it's just another way of doing it
SinFluxx
SinFluxx14mo ago
The only other thing is just to check you're outputting all the required information at the end blobthumbsup
BabySid
BabySidOP14mo ago
wow okay lemem give this a whirl
Isaaaak
Isaaaak14mo ago
Also maybe consider which data type should be used when money is involved
SinFluxx
SinFluxx14mo 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
BabySidOP14mo ago
oh okay so I check for hst after adding the covercharge?
Isaaaak
Isaaaak14mo ago
yep
SinFluxx
SinFluxx14mo ago
Yeah 🙂
BabySid
BabySidOP14mo ago
hmmm okay thank you so much
Isaaaak
Isaaaak14mo ago
because the cover charge is also taxed
BabySid
BabySidOP14mo 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
Isaaaak14mo 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
BabySidOP14mo 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
BabySidOP14mo ago
Also how would I output this ?
No description
Isaaaak
Isaaaak14mo 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
BabySidOP14mo ago
wait I didn't comprehend this
Isaaaak
Isaaaak14mo ago
Console.WriteLine($"Total cost: ${totalCost:F2}"); Copy this, but change it slightly so you get the right text and the right variable
mtreit
mtreit14mo ago
There is a crashing bug in that code.
BabySid
BabySidOP14mo ago
aha gotcha wait wha?
Isaaaak
Isaaaak14mo 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
mtreit14mo ago
See what happens when the user types "three" instead of "3"
Isaaaak
Isaaaak14mo ago
I don't think there are any requirements that the user should be able to input anything else other than integers?
mtreit
mtreit14mo 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
Isaaaak14mo ago
Yep, error-handling is important
BabySid
BabySidOP14mo 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
mtreit14mo 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
BabySidOP14mo 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
mtreit14mo ago
Turn on "warnings as errors" when
Isaaaak
Isaaaak14mo ago
no worries ofc
BabySid
BabySidOP14mo ago
ya'll are life savers thank you so blushowo
Isaaaak
Isaaaak14mo 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
BabySidOP14mo ago
the first one I've calculated I guess for the second one we've been taught double only third one 😁
Isaaaak
Isaaaak14mo 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
BabySidOP14mo ago
I'll check just a sec
Isaaaak
Isaaaak14mo ago
I'll give you a hint if you don't figure it out
BabySid
BabySidOP14mo ago
I discovered something else as well I still can't see this can you figure out why 😢
Isaaaak
Isaaaak14mo ago
I think it looks good?
No description
BabySid
BabySidOP14mo 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
Isaaaak14mo ago
For me it does
No description
Isaaaak
Isaaaak14mo 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
Isaaaak14mo ago
No description
mtreit
mtreit14mo 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
BabySidOP14mo ago
oh yeh I fixed it thank you so much
Isaaaak
Isaaaak14mo ago
still wrong total cost though hmmhm
BabySid
BabySidOP14mo ago
nono
Accord
Accord14mo 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