+ 2

How do I output multiple string variables from a txt file?

I am doing an assignment for my CSIS 123 class and I am having trouble with my outfile. I have declared multiple string variables but they won't print properly in the output txt file. I am using visual studio. I am an amateur just fyi.

1st Oct 2017, 3:17 AM
Jose
Jose - avatar
32 Respuestas
+ 2
Just read it carefully and see if something is wrong one mistake can screw it all
1st Oct 2017, 2:43 PM
Emily
Emily - avatar
+ 2
thank you for the example, but I think that's beyond the chapter we're on. the output should result in press any key to continue, and the actual result should be in another file as directed. this is the input file https://mcckc.blackboard.com/bbcswebdav/pid-1706378-dt-content-rid-5443433_1/courses/1178_LV_CSIS123_42270/input_file.txt and the output file should look something like this Movie Title: Raising_Arizona Budget: $6000000.00 Gross: $22847564.00 Profit Margin: $16847564.00 Movie Title: Vampire's_Kiss Budget: $2000000.00 Gross: $725131.00 Profit Margin: $-1274869.00 Movie Title: The_Wicker_Man Budget: $40000000.00 Gross: $23643531.00 Profit Margin: $-16356469.00 Movie Title: The_Ice_Pirates Budget: $9000000.00 Gross: $13075390.00 Profit Margin: $4075390.00 Movie Title: Krull Budget: $47000000.00 Gross: $16519460.00 Profit Margin: $-30480540.00
1st Oct 2017, 6:43 PM
Jose
Jose - avatar
+ 2
I cant see your input file but Ijust say you are reading profit margin and calculate too in your code I think one task should.
1st Oct 2017, 7:08 PM
Azam
Azam - avatar
+ 2
why you are reading net_profit ?
1st Oct 2017, 7:11 PM
Azam
Azam - avatar
+ 2
then You'll write again and again your block of code.
1st Oct 2017, 8:43 PM
Azam
Azam - avatar
+ 1
this is what I have now. I am able to output 1 result but I am unsure of how to add the other 4? https://code.sololearn.com/c0eYegFTSWla/?ref=app
1st Oct 2017, 5:58 PM
Jose
Jose - avatar
+ 1
this is the input file Raising_Arizona 6000000 22847564 Vampire's_Kiss 2000000 725131 The_Wicker_Man 40000000 23643531 The_Ice_Pirates 9000000 13075390 Krull 47000000 16519460
1st Oct 2017, 7:10 PM
Jose
Jose - avatar
+ 1
your code why is here infile >> net_profit; net_profit = gross - budget;
1st Oct 2017, 7:11 PM
Azam
Azam - avatar
+ 1
should it be above infile?
1st Oct 2017, 7:13 PM
Jose
Jose - avatar
+ 1
your input has three types you are reading four why ?
1st Oct 2017, 7:14 PM
Azam
Azam - avatar
+ 1
just cut infil>>net_profit I think I'll run correctly
1st Oct 2017, 7:16 PM
Azam
Azam - avatar
+ 1
and you are not using loop just wait I try to correct it.
1st Oct 2017, 7:17 PM
Azam
Azam - avatar
+ 1
try it on your system and tell me progress waiting for reply https://code.sololearn.com/c4VOkL29s9E1/?ref=app
1st Oct 2017, 7:19 PM
Azam
Azam - avatar
+ 1
is it working?
1st Oct 2017, 8:14 PM
Azam
Azam - avatar
+ 1
if loop is not being used it will process only 1 time input and write 1 line in output file and finished. I corrected some later check it now
1st Oct 2017, 8:19 PM
Azam
Azam - avatar
+ 1
you can discuss me what you want.
1st Oct 2017, 8:23 PM
Azam
Azam - avatar
+ 1
It is very basic assignment try it your own to separate tasks. you can ask me where is the problem. Dont be afraid . It is simple
1st Oct 2017, 8:31 PM
Azam
Azam - avatar
+ 1
No, dear use loop. otherwise you dont have any idea how many movies are there.
1st Oct 2017, 8:38 PM
Azam
Azam - avatar
+ 1
ok I'll paste here.
1st Oct 2017, 8:48 PM
Azam
Azam - avatar
+ 1
{ infile >> movie_title; outfile << "Movie Title: " << movie_title << endl; infile >> budget >> gross; outfile << setprecision(2) << fixed << showpoint << "Budget:
quot; << budget << endl << "Gross:
quot; << gross << endl; net_profit = gross - budget; outfile << "Profit Margin:
quot; << net_profit << '\n' << endl; }
1st Oct 2017, 8:54 PM
Azam
Azam - avatar