// Flowers.cpp - This program reads names of flowers and whether they are grown in shade or sun from an input  // file and prints the information to the user's screen.  // Input:  flowers.dat. // Output: Names of flowers and the words sun or shade.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 2E: Create a program named FileComparison that compares two files. First, use a text editor such as...
icon
Related questions
Question
// Flowers.cpp - This program reads names of flowers and whether they are grown in shade or sun from an input 
// file and prints the information to the user's screen. 
// Input:  flowers.dat.
// Output: Names of flowers and the words sun or shade.

#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
   // Declare variables here
      
   // Open input file
   
   
   // Write while loop that reads records from file.
   fin >> flowerName;
   
      // Print flower name using the following format
      //cout << var << " grows in the " << var2 << endl;
      
   fin.close();   
   return 0;
} // End of main function
2o https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&id%3897300024&snap
CENGAGE MINDTAP
Opening Files and Performing File Input in C++
f
Opening Files and Performing File
Flowers.cpp
1// Flowers.cpp
Thi
Input
shade or sun from an
2// file and prints t
3 // Input:
flowers.d
Summary
4 // Output: Names of
/>
In this lab, you open a file and read input from that file
6 #include <fstream>
in a prewritten C++ program. The program should read
7 #include <iostream>
and print the names of flowers and whether they are
8 #include <string>
9 using namespace std;
10 int main(O
grown in shade or sun. The data is stored in the input
file named flowers.dat.
11(
12
//Declare variabl
Instructions
13
14
/ Open input file
1. Ensure the source code file named Flowers.cpp is
15
16
open in the code editor.
Hear
/Write while loo
fin >> flowerName;
17
2. Declare the variables you will need.
18
19
3. Write the C++ statements that will open the input file
// Print flower
20
flowers.dat for reading.
21
//cout < var
22
4. Write a while loop to read the input until EOF is
fin.close();
23
reached.
24
return 0;
25 }// End of main funct
5. In the body of the loop, print the name of each
26
flower and where it can be grown (sun or shade).
6. Execute the program by clicking the Run button at
the bottom of the screen.
Grading
When you have completed your program, click the
Submit button to record your score.
0 耳
(7
in
Transcribed Image Text:2o https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&id%3897300024&snap CENGAGE MINDTAP Opening Files and Performing File Input in C++ f Opening Files and Performing File Flowers.cpp 1// Flowers.cpp Thi Input shade or sun from an 2// file and prints t 3 // Input: flowers.d Summary 4 // Output: Names of /> In this lab, you open a file and read input from that file 6 #include <fstream> in a prewritten C++ program. The program should read 7 #include <iostream> and print the names of flowers and whether they are 8 #include <string> 9 using namespace std; 10 int main(O grown in shade or sun. The data is stored in the input file named flowers.dat. 11( 12 //Declare variabl Instructions 13 14 / Open input file 1. Ensure the source code file named Flowers.cpp is 15 16 open in the code editor. Hear /Write while loo fin >> flowerName; 17 2. Declare the variables you will need. 18 19 3. Write the C++ statements that will open the input file // Print flower 20 flowers.dat for reading. 21 //cout < var 22 4. Write a while loop to read the input until EOF is fin.close(); 23 reached. 24 return 0; 25 }// End of main funct 5. In the body of the loop, print the name of each 26 flower and where it can be grown (sun or shade). 6. Execute the program by clicking the Run button at the bottom of the screen. Grading When you have completed your program, click the Submit button to record your score. 0 耳 (7 in
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,