C
C#2mo ago
'brella boy

✅ I DESPERATELY NEED HELP GETTING STARTED

I have 1-2 hours left before a deadline and I only just realised the entire thing is in C#. I need help. Please.
332 Replies
'brella boy
'brella boy2mo ago
I know how to program but in python and not C# So it won’t take ages and I’ve already learnt some parameters I just have no idea what I’m doing wrong at the moment
The Father
The Father2mo ago
is the project big?
'brella boy
'brella boy2mo ago
No not at al All*
The Father
The Father2mo ago
if not then you can probably use chatgpt to convert it
'brella boy
'brella boy2mo ago
Just a few little challenges
The Father
The Father2mo ago
go to chat gpt and convert it
'brella boy
'brella boy2mo ago
But like I don’t learn that way I don’t wanna be cheap I just want some advice I can give you an example hold on
The Father
The Father2mo ago
trust me blud if you have an important deadline in less than 2 hours i highly suggest you use chatgpt right now but i'd be willing to help anyway
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
The deadline is me sleeping I technically have all night I just wanna get it finished quickly
The Father
The Father2mo ago
LOL alright so what are you trying to do
'brella boy
'brella boy2mo ago
Trying to convert farenheight to celcius
The Father
The Father2mo ago
alr
'brella boy
'brella boy2mo ago
But uhh idk how equations work in C# I’m getting a bunch of errors
The Father
The Father2mo ago
ok so first you need to know something unlike in python, c# is a static language so that means that the data type of variables must be specified before you assign them
'brella boy
'brella boy2mo ago
Alright
The Father
The Father2mo ago
so for F1 you need to put "string" before it so
c#
string F1 = Console.ReadLine();
c#
string F1 = Console.ReadLine();
'brella boy
'brella boy2mo ago
Ohhh alright Wait but I want the input to be an integer Or is this a necessary step
The Father
The Father2mo ago
exactly so for F2 you need to make it an int because in this case,
Convert.ToInt32(F1);
Convert.ToInt32(F1);
is converting F1 from a string to an int
'brella boy
'brella boy2mo ago
OOOH RIGHT THANKS
The Father
The Father2mo ago
mhm and for int F2 - 32 = F3 you did it the opposite way first of all it's still similar to python so you say the variable name first and then like in c# you need to specify the data type
'brella boy
'brella boy2mo ago
Oooh mkay
The Father
The Father2mo ago
then the F2 - 32 follows the equal sign
'brella boy
'brella boy2mo ago
So F3 = int F2 - 32; ?
The Father
The Father2mo ago
no int F3 = F2 - 32
'brella boy
'brella boy2mo ago
Ah
The Father
The Father2mo ago
like is said you need to specify the data type before the variable you're initializing
c#
string Word;
int myNumber;
float weight;
double skibiditoiletrating;
c#
string Word;
int myNumber;
float weight;
double skibiditoiletrating;
it's like this every time you make a new variable
'brella boy
'brella boy2mo ago
I’m getting this error now though
No description
'brella boy
'brella boy2mo ago
Wait that sucks
The Father
The Father2mo ago
you didn't specify F2 as an int
'brella boy
'brella boy2mo ago
Oh I missed one
The Father
The Father2mo ago
you got a string from the user input and stored it in F1 then you convert that string to an int and store it in another variable being F2
'brella boy
'brella boy2mo ago
Getting this now
No description
'brella boy
'brella boy2mo ago
Code:
No description
The Father
The Father2mo ago
what did you type as the input
'brella boy
'brella boy2mo ago
Nothing I instantly got an error Code didn’t run
The Father
The Father2mo ago
ok change int to double double is just a float but 64 bit so it can be way longer
'brella boy
'brella boy2mo ago
Alright All 3 of the ints?
The Father
The Father2mo ago
yes it makes more sense anyway considering that temperature can be a double or float anyway
'brella boy
'brella boy2mo ago
Only one more error
No description
'brella boy
'brella boy2mo ago
Then I’m 1/12 through 🥲
The Father
The Father2mo ago
oh yeah ok so another thing
Keswiik
Keswiik2mo ago
how exactly did you get an assignment in a language you don't know, then not realize it until the deadline is a couple hours away?
The Father
The Father2mo ago
in C based languages like C, C++ and C# you need to have a function called "Main" as an entrypoint for the program so rename "FareignheitToCentritrade" to "Main" so Main(string[] args)
'brella boy
'brella boy2mo ago
I’m going to a new school, and I only made up my mind about which school I was going to very recently, and neglected to think that they might be doing a different programming language from my old school, with only a day remaining. It’s supposed to be 3 hours of 16 hours that I’ve completed Alright
The Father
The Father2mo ago
every single c# program must have and can only have one function named Main if it doesn't then it doesn't know how to link, compile, blah blah blah stupid C-like language buzzwords you can change the class Program to FahrenheitToCentrigrade that's fine
'brella boy
'brella boy2mo ago
Mk
The Father
The Father2mo ago
then it makes the code a little more understandable to humans
'brella boy
'brella boy2mo ago
IT WORKED
The Father
The Father2mo ago
ez
'brella boy
'brella boy2mo ago
I LOVE YOU SO MUCH THANK YOU
The Father
The Father2mo ago
np
'brella boy
'brella boy2mo ago
I’ll try to do some others by myself
The Father
The Father2mo ago
alr note that there are a lot of things that you'll have to get used to about c# and other static languages because it's VERY different than python have you worked with other languages before?
'brella boy
'brella boy2mo ago
Nah Only python And not in that much detail tbh
The Father
The Father2mo ago
then you're gonna have to adjust quite a bit but if you don't have much python experience it shouldn't be that bad
'brella boy
'brella boy2mo ago
Also If I want a second subroutine Do I just do repeat static void And name it something other than main?
The Father
The Father2mo ago
soubroutine is just another word for function right? then yes you would
'brella boy
'brella boy2mo ago
Yeah Alright
The Father
The Father2mo ago
although you don't need to use the static modifier for it you can either put "public", "private" or "static" but just put public for now probably the safest option for later but you do need to make the Main function static also if you want to make a function that returns a value, then you need to replace void with the data type void just means the function doesn't return anything
'brella boy
'brella boy2mo ago
Alright Running into a bit of an issue I copy and pasted the function But uh Only the Fahrenheit bit runs
The Father
The Father2mo ago
show the source code mmm
'brella boy
'brella boy2mo ago
No description
The Father
The Father2mo ago
i understand the problem ok so rename both of the functions to what they're supposed to be named then make another function called Main then call both of the functions from that main Main and replace the string[] args with nothing
'brella boy
'brella boy2mo ago
How do I call in C# name(); ?
The Father
The Father2mo ago
yes you won't need any arguments for them since you're getting user input
'brella boy
'brella boy2mo ago
Minor issue
The Father
The Father2mo ago
show
'brella boy
'brella boy2mo ago
No description
The Father
The Father2mo ago
holdup lemme google that
Angius
Angius2mo ago
Bruh Screenshots
'brella boy
'brella boy2mo ago
I deleted discord on my pc Nice tanya pfp
The Father
The Father2mo ago
ok make public to static
'brella boy
'brella boy2mo ago
Done
The Father
The Father2mo ago
does it work
Angius
Angius2mo ago
public and static re two completely different things btw
The Father
The Father2mo ago
yes
Angius
Angius2mo ago
It can be public static just fine
'brella boy
'brella boy2mo ago
Done THANK YOU
The Father
The Father2mo ago
oh yeah np though ignore the public and private keywords for now do you know python classes yet? if not then the words mean nothing to you for now just make everything static
'brella boy
'brella boy2mo ago
Nah never learnt anything in that much detail Alright I’ll attempt the next few on my own
The Father
The Father2mo ago
ez don't forget to google stuff the microsoft .net documentation is dope so when you have a problem just google it and click the first microsoft or stackoverflow link you see
'brella boy
'brella boy2mo ago
I do google stuff it’s how I learnt to convert It’s just that Errors kinda suck
Angius
Angius2mo ago
Errors are amazing
'brella boy
'brella boy2mo ago
Also I have ONE little issue
Angius
Angius2mo ago
They tell you what's wrong
'brella boy
'brella boy2mo ago
To someone who doesn’t program that much They might as well be a foreign languge
The Father
The Father2mo ago
Googling the error:
Angius
Angius2mo ago
No, not really, erros are usually fairly clear and easily googleable
'brella boy
'brella boy2mo ago
Well
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
Can this be solved with google
The Father
The Father2mo ago
this
Angius
Angius2mo ago
No need for Google
The Father
The Father2mo ago
"this name does not exist in the current context" though it should be very easy to fix the variable just doesn't exist in that scope that you're trying to access it from
'brella boy
'brella boy2mo ago
Ohhh OHHH I had them in separate functions
Angius
Angius2mo ago
1. You're trying to use a thing that does not exist 2. You're trying to multiply two strings, which is not a thing 3. Same as 1 4. Same as 1
'brella boy
'brella boy2mo ago
But idk if combining them is a good idea
Angius
Angius2mo ago
No need to combine anything? $scopes
MODiX
MODiX2mo ago
scope A {
thing a;
scope B {
thing b;
}
}
scope A {
thing a;
scope B {
thing b;
}
}
thing a is available in scope A and scope B thing b is available only in scope B
Angius
Angius2mo ago
If you try accessing b in scope A you get the error
'brella boy
'brella boy2mo ago
Oops accidentally made them strings and not doubles They’re all in the same scope I think I’d have to show you
The Father
The Father2mo ago
can you multiply two characters tho? :trollface:
'brella boy
'brella boy2mo ago
Angius
Angius2mo ago
No they're not in the same scope You can use things from a parent scope in the child scope Not between siblings
scope A {
thing a;
scope B {
thing b;
}
scope C {
thing c;
}
}
scope A {
thing a;
scope B {
thing b;
}
scope C {
thing c;
}
}
thing a is available in scopes B and C thing b is available only in scope B thing c is available only in scope C
'brella boy
'brella boy2mo ago
What about ancestors If they’re called that in C# Idk they’re called that in Luau A child of a child
Angius
Angius2mo ago
Same
'brella boy
'brella boy2mo ago
Is the child of the child available to the parent
Angius
Angius2mo ago
scope A {
thing a;
scope B {
scope C {
scope D {
can still use `a` here no problem
}
}
}
}
scope A {
thing a;
scope B {
scope C {
scope D {
can still use `a` here no problem
}
}
}
}
'brella boy
'brella boy2mo ago
Oooh okay Thanks I’ll try this
The Father
The Father2mo ago
are you referencing roblox dev by chance? because that would be completely different
'brella boy
'brella boy2mo ago
Yes
The Father
The Father2mo ago
the problem you're having right now is with scope
'brella boy
'brella boy2mo ago
Uhh I only dabbled in roblox
The Father
The Father2mo ago
ancestors and children are related to object-oriented programming
Angius
Angius2mo ago
Ah, yeah, two different things I'm using terms "parent scope", "child scope", etc. only loosely It's really about nesting, to be more precise A scope has access to the things within it, and things in all scopes it's nested within
'brella boy
'brella boy2mo ago
Is this good?
No description
'brella boy
'brella boy2mo ago
Well. It’s not. I’m getting an error
The Father
The Father2mo ago
and a scope isn't an object do you can't use functions like FindFirstAncestor or GetChildren like in roblox studio lua
'brella boy
'brella boy2mo ago
But I can’t tell if they’re within different scopes 😭
Angius
Angius2mo ago
{} denote a scope It's simple
The Father
The Father2mo ago
D1 is in the scope of ONE() if you want to store D1 within the parent scope you need to make a variable within there ok so do this make a variable within the whole class so before any of the functions and just type double D1;
'brella boy
'brella boy2mo ago
Alright
The Father
The Father2mo ago
static double D1 excuse me and then in the ONE function remove the double keyword since you're not initializing it you don't need to specify the data type you're just assigning it
'brella boy
'brella boy2mo ago
Wait I’m getting completely different errors now
The Father
The Father2mo ago
show the code
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
Oh thr code
Angius
Angius2mo ago
Prolly missed a brace somewhere
The Father
The Father2mo ago
do it inside of the class no you put it outside of the class that's why it says toplevel i think
'brella boy
'brella boy2mo ago
Angius
Angius2mo ago
ye
The Father
The Father2mo ago
if not then yeah probably forgot a brace ok nvm
Angius
Angius2mo ago
Yeah, you know what, I'm out. I don't fancy having to fullscreen red-tinted vertical videos to take a look at the code Peace
'brella boy
'brella boy2mo ago
Well
The Father
The Father2mo ago
ok add public before static
'brella boy
'brella boy2mo ago
I can re-download discord I really do need the help Alright
The Father
The Father2mo ago
i don't think you can make a variable only static in a class
Angius
Angius2mo ago
Discord works in the browser btw You absolutely can make a static field or property without specifying an access modifier
The Father
The Father2mo ago
hm
Angius
Angius2mo ago
C# will simply default to lowest access, private
'brella boy
'brella boy2mo ago
But apparently I have a random account logged into the browser! I can just this there
The Father
The Father2mo ago
just logout
'brella boy
'brella boy2mo ago
Nvm I’m logged in
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
No description
The Father
The Father2mo ago
can you copy the text
'brella boy
'brella boy2mo ago
makes sense using System;
class circles {
static double D1;
static void ONE() { Console.WriteLine("Enter the diameter"); string diameter = Console.ReadLine();
// convert to integer D1 = Convert.ToInt32(diameter);
static void TWO() { Console.WriteLine("Enter the arc angle"); string aa = Console.ReadLine();
// convert to integer double A1 = Convert.ToInt32(aa);
static void THREE() {
double R1 = D1 / 2; Console.WriteLine("The radius is:" + R1);
double AR1 = 3.14 + (R1 * R1); Console.WriteLine("The area is:" + AR1);
double CU1 = 3.14 * D1; Console.WriteLine("The circumference is:" + CU1);
double AL1 = (A1 * CU1) / 360; Console.WriteLine("The arc length is is:" + AL1);
} } } }


}
public static void Main(string[] args) { ONE();
TWO();
THREE();

} }
The Father
The Father2mo ago
alr i should be able to run it onc ei find out how to rename this file in vscode
Angius
Angius2mo ago
$code
MODiX
MODiX2mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
'brella boy
'brella boy2mo ago
oh yeah and why cant i run c# in vscode...
cs
using System;

class circles
{

static double D1;

static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);

static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);

static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);

}
}
}
}



}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
cs
using System;

class circles
{

static double D1;

static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);

static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);

static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);

}
}
}
}



}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
that didnt work
Angius
Angius2mo ago
` not '
The Father
The Father2mo ago
found it
Angius
Angius2mo ago
Close enough
The Father
The Father2mo ago
delete these
No description
'brella boy
'brella boy2mo ago
okie dokie
Angius
Angius2mo ago
None of your methods is terminated with } You got your methods nested within eachother instead
The Father
The Father2mo ago
i wish online compilers had better error stuff vscode is so sexy tho
'brella boy
'brella boy2mo ago
i wanna use vscode but it just DOESNT run idk why
Angius
Angius2mo ago
Wym "doesn't run"?
The Father
The Father2mo ago
what type of computer do you have
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
well wdym i built it myself? like windows???
Angius
Angius2mo ago
Says what's wrong You have no project
'brella boy
'brella boy2mo ago
well im in one right now right
Angius
Angius2mo ago
C# ain't Python, can't run loose files
The Father
The Father2mo ago
no it's a specific thing
Angius
Angius2mo ago
You need the project file
The Father
The Father2mo ago
a c# project
Angius
Angius2mo ago
.cshtml
'brella boy
'brella boy2mo ago
and i make that how
Angius
Angius2mo ago
dotnet new console will create a nice and proper fresh project for you
The Father
The Father2mo ago
in the terminal
'brella boy
'brella boy2mo ago
ill.. download it another time
No description
'brella boy
'brella boy2mo ago
ok back to errors
'brella boy
'brella boy2mo ago
did what you said and got this
No description
The Father
The Father2mo ago
you need to install .NET
Angius
Angius2mo ago
Ah, so you didn't even download .NET and you're wondering why it doesn't run lmao
The Father
The Father2mo ago
do the same thing with A1
'brella boy
'brella boy2mo ago
im just a textbook student man
Angius
Angius2mo ago
1. Can't reference non-static members inside of static members 2. Scopes 3. Scopes
'brella boy
'brella boy2mo ago
delete two "{"
The Father
The Father2mo ago
no
'brella boy
'brella boy2mo ago
OH OOHHH no no i get you
The Father
The Father2mo ago
bro gets me
'brella boy
'brella boy2mo ago
apparently
No description
Angius
Angius2mo ago
The function is local
The Father
The Father2mo ago
copy the source doe and send it
Angius
Angius2mo ago
Nested Functions go into classes
The Father
The Father2mo ago
mm
Angius
Angius2mo ago
Functions can go into other functions if you know what you're doing So in this case, let's say they cannot
The Father
The Father2mo ago
send the source code and i'll fix that rq
'brella boy
'brella boy2mo ago
oo
using System;

class circles
{

static double D1;
static double A1;

static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);

static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);

static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);

}
}
}






public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
using System;

class circles
{

static double D1;
static double A1;

static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);

static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);

static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);

}
}
}






public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
yeah,... i don't.
Angius
Angius2mo ago
I'd tell you to use $prettycode to clean up this unindented mess
MODiX
MODiX2mo ago
To format your code in Visual Studio, Visual Studio Code, Rider, use the following shortcut:
Visual Studio CTRL + K + D
Rider / Resharper CTRL + ALT + L
Visual Studio Code SHIFT + ALT + F
Visual Studio CTRL + K + D
Rider / Resharper CTRL + ALT + L
Visual Studio Code SHIFT + ALT + F
NOTE: the first key must be held while doing it. https://cdn.discordapp.com/attachments/569261465463160900/899513918567890944/2021-10-18_01-26-35.gif
The Father
The Father2mo ago
using System;

class circles
{

static double D1;
static double A1;
// Function 1
static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);
}
// Function 2
static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);
}
// Function 3
static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);
}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
using System;

class circles
{

static double D1;
static double A1;
// Function 1
static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);
}
// Function 2
static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);
}
// Function 3
static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 + (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360;
Console.WriteLine("The arc length is is:" + AL1);
}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
Angius
Angius2mo ago
But I don't suppose it will work with an online compiler
'brella boy
'brella boy2mo ago
PRAYING this works i just want to sleep ill firm the fail
The Father
The Father2mo ago
just do it in the online compiler you can google how to setup visual studio tomorrow
'brella boy
'brella boy2mo ago
EVERYTHINGS PERFECT AND YOURE A GODSEND except uh... one small issue logic error!
Angius
Angius2mo ago
That's also true, we're talking VS Code here and we should really be talking VS 2022
'brella boy
'brella boy2mo ago
arc length isnt right
No description
'brella boy
'brella boy2mo ago
it should print this
No description
'brella boy
'brella boy2mo ago
not bothering to check anything else but yk
No description
Angius
Angius2mo ago
I'd tell you to use the debugger to check, but... online compiler
'brella boy
'brella boy2mo ago
yup uhh
Angius
Angius2mo ago
My bet is it's because of the 360 Try 360.0
'brella boy
'brella boy2mo ago
mk also prints 0
Angius
Angius2mo ago
Also, Convert.ToInt32() will just throw an error if you give it something like 123.456, btw
'brella boy
'brella boy2mo ago
eh its fine i doubt my teacher will care
Servator
Servator2mo ago
How is your methods access variables ?
'brella boy
'brella boy2mo ago
im doing this btw
No description
Servator
Servator2mo ago
$codeblock
'brella boy
'brella boy2mo ago
so its arc length thats not working
Angius
Angius2mo ago
We can do the debugging the hard way. Before the calculation that goes wrong, print out all of its components to see what they are
Servator
Servator2mo ago
Am i missing something?
The Father
The Father2mo ago
send the source doe code again
'brella boy
'brella boy2mo ago
mk
The Father
The Father2mo ago
whenever there's a problem and you make a change send the source code
'brella boy
'brella boy2mo ago
oh i didnt change anything but
using System;

class circles
{

static double D1;
static double A1;
// Function 1
static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);
}
// Function 2
static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);
}
// Function 3
static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 * (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360.0;
Console.WriteLine("The arc length is is:" + AL1);
}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
using System;

class circles
{

static double D1;
static double A1;
// Function 1
static void ONE()
{
Console.WriteLine("Enter the diameter");
string diameter = Console.ReadLine();

// convert to integer
D1 = Convert.ToInt32(diameter);
}
// Function 2
static void TWO()
{
Console.WriteLine("Enter the arc angle");
string aa = Console.ReadLine();

// convert to integer
double A1 = Convert.ToInt32(aa);
}
// Function 3
static void THREE()
{

double R1 = D1 / 2;
Console.WriteLine("The radius is:" + R1);

double AR1 = 3.14 * (R1 * R1);
Console.WriteLine("The area is:" + AR1);

double CU1 = 3.14 * D1;
Console.WriteLine("The circumference is:" + CU1);

double AL1 = (A1 * CU1) / 360.0;
Console.WriteLine("The arc length is is:" + AL1);
}

public static void Main(string[] args)
{
ONE();

TWO();

THREE();


}
}
ill double check if my maths is right i guess.. yeah nothing wrong w my maths
MODiX
MODiX2mo ago
Angius
We can do the debugging the hard way. Before the calculation that goes wrong, print out all of its components to see what they are
React with ❌ to remove this embed.
'brella boy
'brella boy2mo ago
i mean i basically do with radius, area and circumference since arc length is just arc angle and circumference but i mean ill reprint it yeah
Angius
Angius2mo ago
Console.WriteLine($"({A1} * {CU1}) = {A1 * CU1}");
double AL1 = (A1 * CU1) / 360.0;
Console.WriteLine("The arc length is is:" + AL1);
Console.WriteLine($"({A1} * {CU1}) = {A1 * CU1}");
double AL1 = (A1 * CU1) / 360.0;
Console.WriteLine("The arc length is is:" + AL1);
To see what A1, CU1, and A1 * CU1 are
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
im seeing it.. its arc angle it thinks its 0 for some reason
Angius
Angius2mo ago
No description
Angius
Angius2mo ago
This creates new variable Local to TWO() function It does not assign this value to the A1 field you have in your class
Servator
Servator2mo ago
That's what i was talking about :Sad:
'brella boy
'brella boy2mo ago
oooh. so do i fix that by putting it somewhere else..?
Angius
Angius2mo ago
You fix it by removing the double
The Father
The Father2mo ago
oh yeah
Angius
Angius2mo ago
So it assigns to the existing field instead of making a new variable
Servator
Servator2mo ago
No description
Servator
Servator2mo ago
It should output something like this
The Father
The Father2mo ago
also the convert is wrong
Angius
Angius2mo ago
No description
Angius
Angius2mo ago
One works, the other does not
The Father
The Father2mo ago
do Convert.ToDouble
Angius
Angius2mo ago
Take note of the difference
'brella boy
'brella boy2mo ago
mk
The Father
The Father2mo ago
replace both of them
Angius
Angius2mo ago
It will be cast to double anyway
The Father
The Father2mo ago
when it converts it to an int it just rounds it
Angius
Angius2mo ago
And if anything, you should just get rid of Convert and use double.Parse()
'brella boy
'brella boy2mo ago
will do
Angius
Angius2mo ago
double.TryParse() ideally, but we're not there yet
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
this might be the compiler im using but idk
The Father
The Father2mo ago
ToDouble
Angius
Angius2mo ago
No such thing as Double32 type Yeah
The Father
The Father2mo ago
double is just a 64 bit float
'brella boy
'brella boy2mo ago
ahh
The Father
The Father2mo ago
float is 32 bit
Angius
Angius2mo ago
Convert.ToDouble() (eugh. yuck, bad) double.Parse() (eh, sure, will do) Either of those works
'brella boy
'brella boy2mo ago
SUCCESS!! you're all Godsends now I'm going to sleep before I actually die
No description
The Father
The Father2mo ago
ez
'brella boy
'brella boy2mo ago
thank you for your time.
The Father
The Father2mo ago
np why is parse better i know why TryParse is but no Parse
Angius
Angius2mo ago
Convert will take a null and gladly treat it as a 0
MODiX
MODiX2mo ago
Angius
REPL Result: Success
Convert.ToInt32(null)
Convert.ToInt32(null)
Result: int
0
0
Compile: 411.577ms | Execution: 18.054ms | React with ❌ to remove this embed.
The Father
The Father2mo ago
hm
MODiX
MODiX2mo ago
Angius
REPL Result: Failure
int.Parse(null)
int.Parse(null)
Exception: ArgumentNullException
- Value cannot be null. (Parameter 's')
- Value cannot be null. (Parameter 's')
Compile: 305.950ms | Execution: 24.735ms | React with ❌ to remove this embed.
Angius
Angius2mo ago
You gotta remember that Console.ReadLine() returns a string? not a string So it's best to handle that possible null properly
The Father
The Father2mo ago
ohh i didn't know that
Angius
Angius2mo ago
Well, properly-ish
The Father
The Father2mo ago
because the null terminator?
Angius
Angius2mo ago
ye Actually Ctrl+Z followed by Enter will send a null for example Also, other applications can just send a null stream and what not Lotsa edge cases
The Father
The Father2mo ago
hm
'brella boy
'brella boy2mo ago
oh man im supposed to make like 3-6 more programs 😭 can anyone help me with 1 more error? its just a simple one though didnt pick complicated code this time
Angius
Angius2mo ago
Sure
'brella boy
'brella boy2mo ago
oh nvm i fixed it im actually learning 🥹
Angius
Angius2mo ago
'Ere you go1
'brella boy
'brella boy2mo ago
nope nvm
Angius
Angius2mo ago
:kekw:
'brella boy
'brella boy2mo ago
the C2F is just kinda excess but uh
No description
'brella boy
'brella boy2mo ago
for once my code isnt a muddlke
Angius
Angius2mo ago
Did you perhaps mean to use else if? Also, use braces, they make things cleaner This ain't Python
'brella boy
'brella boy2mo ago
where do i put the... brackets?
No description
'brella boy
'brella boy2mo ago
they still confuse me but ill try
Angius
Angius2mo ago
if (something)
{
// do stuff
}
else if (something_else)
{
// do other stuff
}
else
{
// do another stuff entirely
}
if (something)
{
// do stuff
}
else if (something_else)
{
// do other stuff
}
else
{
// do another stuff entirely
}
'brella boy
'brella boy2mo ago
but like else if... what?
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
ill use the braces ty
Angius
Angius2mo ago
If job is engineer, else if the job is developer, else if the job is fisherman, else if the job is a waiter, else there's no job
Angius
Angius2mo ago
No description
Angius
Angius2mo ago
here
'brella boy
'brella boy2mo ago
oooh mk
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
so like this? and i THINK thats how braces are
Angius
Angius2mo ago
yep
'brella boy
'brella boy2mo ago
i must be doing something wrong..
No description
Angius
Angius2mo ago
I see no errors
'brella boy
'brella boy2mo ago
it might be the code thingy im using
Angius
Angius2mo ago
Idk what you're using, but when it comes to online compilers Sharplab and Dotnet Fiddle are the only ones I see recommended The proper recommendation of course is to just use VS 2022 But far as web goes, it's those two
'brella boy
'brella boy2mo ago
i was using dotnet fiddle but it just kinda crashes
Angius
Angius2mo ago
Right And Sharplab does not allow for user input So ig keep chugging along, using what you're using
'brella boy
'brella boy2mo ago
ill just submit this anyway and hope the teacher doesnt notice even though im literally only half done 😊
Angius
Angius2mo ago
Would've gone so much faster and easier if you just installed VS 2022 Code completion, errors shown even before the code is ran, all that good stuff
'brella boy
'brella boy2mo ago
alr wait i got one more in me... this one requires a bit of explanation though ok so i need to input a sum of money lets say £24.50 and i need the program to round it up to the nearest £ so in this case £25 and then "deposit" the change which would be 0.50
Angius
Angius2mo ago
% will be your friend And Math.Round() method
'brella boy
'brella boy2mo ago
mk so i get the user to input a number which is double right? then I use math.round to round it up then i do rounded up number - initial number
Angius
Angius2mo ago
ye
'brella boy
'brella boy2mo ago
ok ill try that
Angius
Angius2mo ago
That works too, no need for %
'brella boy
'brella boy2mo ago
do I
No description
'brella boy
'brella boy2mo ago
REALLY have to separate them AGAIN
Angius
Angius2mo ago
No, why?
'brella boy
'brella boy2mo ago
well whys it saying they dont exist
Angius
Angius2mo ago
Yeah M2 = 7; is assigning the value of 7 to an existing M2
'brella boy
'brella boy2mo ago
ooooooooooh
Angius
Angius2mo ago
It has never actually been declared anywhere
'brella boy
'brella boy2mo ago
so. where do I declare it?
Angius
Angius2mo ago
So double M2 = ...
'brella boy
'brella boy2mo ago
should I just set it to 0 beforehand and let it update
Angius
Angius2mo ago
No, you can do it on one line You can do
int x;
x = 69;
int x;
x = 69;
or
int x = 0;
x = 69;
int x = 0;
x = 69;
but it's just useless code, You can just do
int x = 69;
int x = 69;
like you've been doing
'brella boy
'brella boy2mo ago
ahhh mk
'brella boy
'brella boy2mo ago
sorry for bombarding you with problems that probably have easy solutions but
No description
'brella boy
'brella boy2mo ago
im so tired rn and i cant think straight i just need to get this do ne
'brella boy
'brella boy2mo ago
No description
'brella boy
'brella boy2mo ago
nvm fixed one it works thanks not bad considering I started learning C# 3 and a half hours ago
Angius
Angius2mo ago
Yeah lol
'brella boy
'brella boy2mo ago
and once again, nice tanya pfp real underrated show
Angius
Angius2mo ago
Oh yeah Can't wait for S2
'brella boy
'brella boy2mo ago
ITS COMING ?
Angius
Angius2mo ago
It is, we just don't know when, yet Been a good while since they released the movie, though So it can't be that much longer, can it?
'brella boy
'brella boy2mo ago
Surely not. I'm almost caught up on the manga and don't want to have to wait just yet..
Evyr
Evyr2mo ago
be wary with Math.Round, by default it rounds to even. There's an overload that lets you pass in a MidPointRounding enum, eg MidPointRounding.AwayFromZero which would behave as you'd expect rounding to normally
'brella boy
'brella boy2mo ago
So it’ll never round up to an odd number? Weird… Well I’ll keep that in consideration thanks
Evyr
Evyr2mo ago
iirc it's do to with rounding conventions in finance, or something like that
'brella boy
'brella boy2mo ago
Ah
Want results from more Discord servers?
Add your server