OP here, this is what I got so far, it's my first C++ thing I ever did so it's probably retarded
Owen Perry
Consider switching majors
Just cin a float for conversion factor then multiply 1-10 by the factor and print it out as a nice pretty table.
Elijah Lewis
A for loop will let you do this in 2 lines of code.
Maybe programming isn't for you?
Brayden Diaz
I know it's not, but I need it for my logistics major, I just want to pass it and forget it
So it would be something like
double x; cin >> x; cout
Aiden Cruz
Fuck off and pay a classmate to do your homework, you dumb MBA-shitter.
Dominic Torres
pretty much. Most of the programming is pretty printing. Its just multiplication.
There are better ways to do it, but even you should be able to hack out a solution in at most 10-15 minutes
Colton Morales
What the fuck, OP. The instructions clearly state the expected output, and you immediately start typing bullshit and adding typos. Convertion? wtf is that. Please go to office hours. You are not going to pass this class.
Caleb Ortiz
"... into the destination currency, using conversion factor provided by the user", and thanks for pointing out the typo, that happens to me some time since English isn't my first language пeтyшoк oбocцaный
Benjamin Butler
jesus christ op this is pre programming knowledge literal bottom of the barrel shit
YOUR OUTPUT: Hello,\n \n Press 1+Enter to do a dollars to euros conversion, Press 2+Enter to do a euros to dollars conversion :
FUCKING CAPSLOCK IM SO MAD If i was grading this I would give you a 0 even if it worked perfectly. How are graders supposed to diff output when no1 pays attention to guidelines.
Luis Brooks
I didn't know how to make it the right way lol
Kayden Moore
Protip: use boolean for the options, as you dont need more than 2 options
Charles Phillips
wew lad you mad?
Hunter Foster
It's literally just type what you see them asking you to type. Make it look like theirs. Even Dudley from the Royal Tenanbaums could do that one. Please fix the output, and I'll be glad to help with the rest of the logic.
Christian Fisher
cin.get(x) a = 0 For (i = 1; i < 11; i++) a = i*x+ a cout
Jackson Carter
is this better?
Jack Cook
that looks like it has potential in it, looking into it now
Jonathan Cruz
Delete the first two cout lines. Also using namespace is bad practice, but that's okay in this kind of program. Once you get the conversion rate from standard input, print the EUR USD table header and then all you have is a for loop to write. for (int i = 1; i
Isaac Green
Im a dumbass friend, forgot define the int.
cin.Get(x) a = 0 For (int i = 1; i < 11; i++) { a = i * x + a; cout
Alexander Young
this is super wrong
Justin Sullivan
super wrong v2.0
Kevin Watson
Where in the program does it ask you to say hello?
Jason Jones
hilariously incorrect I LOVE THIS THREAD
Owen Walker
Like i said breh. No clue how c++ works, whats wrong about this
Ryder Reed
every time you go through the loop, you're adding a to itself and then also adding the conversion rate multiplied by i. All the question asks is to print i*conversion rate in increasing order from 1 to 10.
Samuel Lopez
Cin and cout are fucking retarded. They are objects that use bit shift operator to print or read text. Why the fuck? What was wrong with printf function?
Parker Sanchez
float factor; cin >> factor; int i, value; cout
Dylan Rodriguez
agree. love me some printf.
Robert Allen
Really? I made it so that it output a every time it added i * x to a So i figured it would do
i * x + a = 1.4 Then on the next pass its - Okay yeah i see where the mistake is. Thanks user i'm an idiot
Justin Hughes
well, it must greet the user, am I wrong? thank you, gonna be testing it now no problem bud, any input is nice lol
Kayden Gomez
I don't like printf. Overloaded operators 4 lyfe.
No, really, printf has the look and feel of deprecation compared to cout.
Colton Walker
Thank you, I'm starting to get something out of that, but for some reason it abruptly disappears
Dylan Anderson
>yfw printf is slower than std::cout
Zachary Davis
You have no idea what you're talking about.
C style variable arguments are great and consistent.
Stream operator overloading with the bitwise shift operator is the epitome of shit.
Somewhat valid, cout adds inheritibility and all that shit listed on stackoverflow. Not that stack overflow isn't often wrong.
Jordan Hill
Hello, so I am hearing you are having troubles with your HW assignment? No problem friend. I will assist you with your problem. int euro=0; int usd=0; int xRate=0; int choice=0; int obama=1; cin>>choice; cin>>xRate;
while(choice!=0&&obama){ if(obama) {cout
Aiden Martin
Guessing you're using an IDE like VS. Try just running the binary from the cmd. Or add 'getch();' before the closing brace.
Gavin Miller
lol'd. Also is there some tag I don't know about? It looks like there is.... shit
James Rivera
thank you very much for you input friend, your warmth will caress me in the night
Oliver Phillips
>using namespace std kek
Julian Barnes
for (int i = 1; i
Chase Jones
already mentioned that not that he cares or even a grader would care
Lincoln Cook
he's not a CS major fuck, am I the only one in this thread that reads other posts?
Lincoln Perez
Okay I will be the autist here. Run this. Use std::setw to format the table
Chances are you are right but I still prefer cout over printf. cout just seems easier and more flexible than using printf. Definitely sounds like VS. When I was taking courses, I resolved to use system("pause") because it was the quickest answer google could give me. It's a bad practice and I've long since stopped. A better way to do stop VS from closing the console window without constantly adding a line to your programs just for that is to use the feature "Run without debugging" , or, ctrl+f5 (you can add the button to the window frame, too).
Adrian Gutierrez
+1 for casting to float -10 for unsafe casting
Jaxson Reyes
i'm not a CS major either
this is basic math
Kevin Rogers
Lol
CS is for people who are to dumb for math and too dumb for science
Cooper Cook
It's what they're teaching students to do these days. Sure enough, it's confusing as fuck to a complete novice when they go online to seek help and see std:: prefixing a bunch of things that their textbook would print plainly, ie cout and vector.
Benjamin Robinson
Nope, CS major here. Minor in math. Always did better in math courses. Could have switched to double major but I prefer CS courses for their focus on application.
Samuel Butler
WHY are you using VS? WHY are you coding in Windows?
Sebastian Garcia
We did it Reddit!
Jason Peterson
...
Nolan Thompson
yeah, especially with c/c++. At least use cygwin, super easy to install just make sure u check the boxes for gcc/g++ and vi/vim (if available).
Samuel Jones
Press Windows key + r Type cmd You should see "C:\Users\yourusername>" with a blinking _ Type cd (meaning change directory) (DON'T PRESS ENTER) Now, the goal is to change to the directory with your Visual Studio project By default, this is C:\Users\you\Documents\Visual Studio 15\Projects\projectname You can type part of the directory name and press Tab to complete it For example, you start out with C:\Users\you type cd Doc and press Tab, and it will automatically complete to look like cd Documents You can press \ (backslash) and then type another folder name to complete the name of a folder inside Documents For example, you have cd Documents\Vis and you press Tab, and it changes to cd "Documents\Visual Studio 15" (the quotations are necessary because the directory name has a space) Then delete the last quotation mark, press \ (backslash), start typing the name of the project, press Tab Make it so it looks like cd "Documents\Visual Studio 15\Projects\projectname\Debug" (15 may be a different number) After that press Enter. Not it should say C:\Users\you\Documents\Visual Studio 15\Projects\projectname\Debug> Start typing the name of the project and press Tab. It should autocomplete to something like projectname.exe Press Enter, and you should see the output of your program.
Aiden Thomas
huh?
Nicholas Fisher
>cygwin Good G*d, no!
Adam Anderson
Should've majored in tripal integrals instead
Carter Jackson
Hey, I hate emulating too, but definitely better than whatever windows IDEs are out there.
Lucas Roberts
C style casting is perfectly valid if the types are integral. You can replace it with static_cast if you're that anal about it.
Aiden Smith
This is why people learning to code shouldn't use IDEs fyi
Jackson Taylor
>tripal integrals Showing results for triple integrals instead Search instead for tripal integrals? God I hope you don't have a college degree.
Evan Gonzalez
Now that OP's homework has been done by autists can we talk about 17-dimensional hypercubes?
PLEEEEEASE?
Jordan Hernandez
No. Windows has a great ide for Windows development. Cygwin is a bandaid for lazy people and you are better off going mingw or just full linux instead
Cooper Smith
>my little shitposter cant be this new
Sebastian Davis
When I was doing HW assignments, I would always favor using double over float. Something about decimal number precision iirc. So, basically anything that had me print or use a number with several decimal places was full of double declarations instead of float. How dumb was that?
Kevin Sullivan
I'll take your word for it. I really don't like cygwin either but it's closer to Linux and you don't have to fuck around with IDEs and waste your brain on autocomplete.
holy fuck this is hard mode. just use "start without debugging" / ctrl+f5
John Sanders
Float is expensive. At that level final decimal precision can probably be handled with doubles
Thomas Thomas
If you want something "closer to Linux" I emplore you to use mingw then.
Isaiah Torres
Okay, what? Am I the only one who thinks this guy might have brain issues, or am I a complete idiot? >inb4 both Doubles are double precision (64-bit) whereas floats are 32 bit single precision. How is float more expensive than double?
Adam Parker
>this is hard mode. Literally all he is doing is changing directory on a command line and then running a program. That is the most basic you could possibly do.
Do winplebs really not know how to use an operating system?
Robert Peterson
No, I'm a Linux fag, definitely only use windows for the occasional game, but it's been months since I booted into win7. Not looking to do any development on windows.
Camden Evans
literally all he is doing is expending a lot more energy with the manual labor of typing and clicking and typing and clicking when even litterally adding one dumbfuck line to every program would be easier literally
Easton Williams
You mean these?
Colton Rogers
If I'm not misunderstood float uses IEEE standard, with mantessas and shit, while double is just a wide integer basically
Zachary Hughes
Just scanning his long ass post made it seem like a lot of shit just to keep it from exiting immediately. I still haven't read that whole thing. Shoulda put a tl;dr at the end.
Josiah Walker
See, this is why I thought using doubles errywhere was fine but then I read that floats are 4 bytes whereas doubles are 8, thus, potentially wasteful (even if it was for the simple shit I was doing).
Ayden Mitchell
;-)
Grayson Davis
Single precision (float) gives you 23 bits of significand, 8 bits of exponent, and 1 sign bit.
Double precision (double) gives you 52 bits of significand, 11 bits of exponent, and 1 sign bit.
Both use encoding and need to be decoded. Pretty sure I'm correct in saying that doubles are heavier than floats in both space and decoding complexity.
Connor Sanchez
>calling people out while unironically referring to programming as coding
Zachary Reed
Good call, but the perf difference is more from calculation time than mem size
Logan Mitchell
But I'm liking this discussion and would love to be proven wrong.
Carson Johnson
see amiwrong?
Cooper Peterson
Doubles are NOT heavier than floats. What exactly do you think a FLOP is?
Jordan Lewis
Enlighten me
Julian Perry
floating point operation. Where's your argument exactly? Would still love if someone would prove me wrong. Keyword: prove.
Landon Hill
i made the code to the 2 option. i'm beginner too, notations are in portuguese int choice; cin >> choice; if (choice==2){ cout > x; int i;//i=moeda no caso 1 vai ser o dolar for (i=1;i
Jaxon Reyes
hey OP i did your homework
I'll post the solution if you post a timestamped picture of yourself holding a sign saying "MAKI MAKI GIMMIE DAT FAKI"
Easton Sanders
People use FLOPS because a flop is the most expensive operation, making it a more meaningful measure of power.
Eli Carter
Doubles are double-precision floats. AKA they are just bigger floats (4 bytes larger, so obviously in terms of space they are heavier)
I'm beginning to think this thread is 99% trolls.
Owen Walker
hahhaaaa
What year are you? Take a fucking proof class please
Eli Wilson
Not an argument
I've graduated. Tell me what I said wrong...
Blake Green
senpai pls
Kayden Lee
Okay, here's what your mistake was: While doubles should be the default in modern programs, floats are less resource intensive. Doubles are literally double precision floats. WTF
Leo Gonzalez
fucking god it said the image was attached but it wasn't
Tyler Nguyen
>People use FLOPS because a flop is the most expensive operation, making it a more meaningful measure of power. People use flops because the vast majority of supercomputers are interested in floating point operations for their calculations.
data Currency = USD | EUR deriving (Eq, Show, Read)
main ∷ IO () main = do let to = (,) let conversions = [USD `to` EUR, EUR `to` USD] let printConv (a,b) = show a ++ " -> " ++ show b putStrLn "Options:" foldM_ (\i x → do putStrLn $ show i ++ ": " ++ printConv x return (i + 1) ) 1 conversions
putStr "\nPlease select an option: " option ← read getLine ∷ IO Int let choice@(from,to) = conversions !! (option - 1)