The following
«include <iostream>
«include <fstream»
«include <cctype> // Needed for toupper
using namespace std;
int main()
{
// Define a file stream object here and use
// the file stream to open the file phones.dat
string name, phone;
cout << "This program allows you to add names and phone\n";
cout << "numbers to phones.dat.\n";
do
{
char add;
cout << "Do you wish to add an entry?";
cin >> add;
if (toupper(add) == 'Y')
{
// Write code here that asks the user for a name
// and phone number, then stores it in the file
}
} while (toupper(add) = 'Y');
// Don't forget to close the file.
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Starting Out with C++: Early Objects
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: Early Objects (6th Edition)
Java How To Program (Early Objects)
Introduction To Programming Using Visual Basic (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science: An Overview (12th Edition)
- (Data processing) Write a C++ program that reads the file created in Exercise 4, permits the user to change the hourly wage or years for any employee, and creates a new updated file.arrow_forwardJAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU. import java.io.*;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please enter the file name: "); while (true) { String fileName = scanner.nextLine(); File file = new File(fileName); if (file.exists() &&…arrow_forwardJAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU. import java.io.*;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please enter the file name: "); while (true) { String fileName = scanner.nextLine(); File file = new File(fileName); if (file.exists() &&…arrow_forward
- Problem Definition You are provided with a text file (employees.txt) containing a number of text lines. Each line contains a record of one employee. Each record has three attributes: Title: string, Prof. (Professor) or Dr. (Doctor). First and Last names: string. Salary: float number. The attributes are separated by the character (',). Figure 1.a, 1.b, and 1.c show a sample of employees.txt files. Dr., Julia Scott, 141518 Dr., Julia Scott, 141518 Prof.,Joan Stewart, 111673 Mr.,Ali Al-shukaili,122311 Prof., Sana Al-Abri, 131673 Prof.,Joan Stewart Dr., Fadi A1-Rasdhi, 153790 Ms., Salwa Al-Youssfi, 111675 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, unknown Dr. :Benjamin Russell:117642 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, 67251 Dr., Benjamin Russell,117642 Prof., Patrick Bailey, 72305 Dr., Ralph Flores, 118457 Dr., Douglas Flores, 181793 Dr., Lillian Brown, 67251 Figure 1.b: A sample of the text file 'employees.txt" Figure 1.a: A sample of the text file 'employees.txt' without…arrow_forwardC++ formatting please Write a program (not a function) that reads from a file named "data.csv". This file consists of a list of countries and gold medals they have won in various Olympic events. Write to standard out, the top 5 countries with the most gold medals. You can assume there will be no ties. Expected Output: 1: United States with 1022 gold medals 2: Soviet Union with 440 gold medals 3: Germany with 275 gold medals 4: Great Britain with 263 gold medals 5: China with 227 gold medalsarrow_forwardProgram in C++ author_titles_data.txt file Jane Austen; 6Charles Dickens; 20Ernest Hemingway; 9Jack Kerouac; 22F. Scott Fitzgerald; 8Mary Shelley; 7Charlotte Bronte; 5Mark Twain; 11Agatha Christie; 73Ian Fleming; 14J.K. Rowling; 14Stephen King; 54Oscar Wilde; 1arrow_forward
- Can you please help me do this C++ program, its for a class called Object Oriented Programming inarrow_forwardPython - Next Birthdate In this task, we will write a program that reads birthdate data from a given CSV file, and given the current date, determines which person's birthday will be celebrated next. Create a function with the following signature: nextBirthdate(filename, date) filename: parameter, which represents the CSV filename. date: parameter, which represents the current date. The function should open the CSV file, read the birthdate data, and determine which person's birthday will be celebrated next, given the current date. The name of the person should be returned. In other words, given a date, find the person whose birthday is next. Sample Run birthdates.csv Draven Brock, 01/21/1952 Easton Mclean, 09/02/1954 Destiny Pacheco, 10/10/1958 Ariella Wood, 12/20/1961 Keely Sanders, 08/03/1985 Bryan Sloan,04/06/1986 Shannon Brewer, 05/11/1986 Julianne Farrell,01/29/2000 Makhi Weeks, 03/20/2000 Lucian Fields, 08/02/2018 Function Call nextBirthdate("birthdates.csv", "01/01/2022") Output…arrow_forwardC++ Language Order Processing Order E 46 H 76 D 2 G 7arrow_forward
- Please help me with this lab senario.arrow_forwardUnfortunately, the change from int to Month means that it's harder to read Date objects from an input file, since it doesn't work if a user enters Date::jan. Write a toMonth function that can be used to enter a month as an integer. Throw invalid_argument if it fails. Month m = toMonth (3); // returns Month::mar udts.cpp 1 #include 2 #include 3 #include "date.h" using namespace std; 4 6. /** Construct a valid Month. 7 8. @param mm the month in the range 1-12 9. @exception throw invalid_argument if out of range. @return the correct Month. 10 11 */ Month toMonth(int mm) { 12 13 14 15 16 17 } Demo.cpp 1 #include 2 #include 3 #include "date.h" 4 using namespace std; 5 6 int main() 7 { cout « "Enter date as mm/dd/yyyy: "; int mm, dd, yyyy; char slash; cin >> mm >> slash » dd >> slash » yyyy; 8 10 11 12 13 try { Date d = makeDate (toMonth(mm), dd, yyyy); cout <« "The date is " << d << endl; } catch (invalid_argument& e) { cout « e.what() « endl; } 14 15 16 17 18 19 20 21 22 }arrow_forwardAverage grades bar chart Write a python program grades.py that reads a file of assignment grades and draws a bar chart of the average grades for each assignment. Save the figure as grades.png in the current working directory. The format of a line in the file is: assignment_type grade Note that there is a single space between the assignment type and the grade. E.g. exam 92.80 Your program must contain the following functions: Function name Function description Function input(s) Function return value(s) get_grades() This function takes a file name as input and populates a dictionary containing the assignment types and grades. Filename string Dictionary of grades main() This function prompts for the grades file name. Next, it calls the functions get_grades(). Next, it draws the bar chart of the average grade for each assignment. Hint: You can use the mean function of the statistics module to calculate the average of a list. None None Use the starter…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning