got stuck in the boolean function. Not sure if my function protypes and calls are correct either.    Program is in c+

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I got stuck in the boolean function. Not sure if my function protypes and calls are correct either. 

 

Program is in c++

//
E#include <iostream>
#include <string>
===============
=====
#include <fstream>
using namespace std;
void getlogin (string id, string& pw);
bool validateLogin (string id, string pw);
void showResult();
Qint main()
{
string id;
string pw;
getlogin (id, pw);
validatelogin(id, pw);
showResult();
}
Evoid getlogin (string& id, string& pw)
{
cout << "Enter your ID: ";
getline(cin, id);
cout << "Enter your PW: ";
getline(cin, pw);
a bool validateLogin (string id, string pw)
{
bool result;
ifstream infile();
infile.open("login.txt");
Transcribed Image Text:// E#include <iostream> #include <string> =============== ===== #include <fstream> using namespace std; void getlogin (string id, string& pw); bool validateLogin (string id, string pw); void showResult(); Qint main() { string id; string pw; getlogin (id, pw); validatelogin(id, pw); showResult(); } Evoid getlogin (string& id, string& pw) { cout << "Enter your ID: "; getline(cin, id); cout << "Enter your PW: "; getline(cin, pw); a bool validateLogin (string id, string pw) { bool result; ifstream infile(); infile.open("login.txt");
HW_7a-1c
Write a program that prompts the user to enter an ID and Password. The ID and Password the user
enters are compared to the ID and Password in a file. If the user's ID and Password match the ones
on file, VALID should display on the screen. Otherwise, INVALID should display.
1. In your project, create a new text file named: login.txt
A File
Edit
View
Project
Build
3 -* 2-
Source.cpp
Enter an ID and Password, like this:
tommy
2 12345
2. Use these 3 functions in this program:
getLogin, validateLogin and showResult
3. In main(), declare 2 string variables: id and pw
4. In main(), call a function named: getLogin
A void function.
In the function, the user is prompted to enter an ID and Password (see output).
/* OUTPUT
Enter your ID : tommy
User is asked for an ID and PW in the getLogin function.
Enter your PW
12345
Valid.
Valid or Invalid is displayed in the showResult function.
* /
5. Then, in main(), call a function named: validateLogin
The function returns a bool value (true or false).
Pass the user's id and pw to the function.
In the function, open the login.txt file.
Read in the lID and PW in the file into two string variables declared in the function.
Name the two variables: filelD and filePW
Still in the function, compare the filelD and filePW to the id and pw that were passed
from main().
If they are the same, the function returns true. Otherwise, false is returned.
The bool value returned to main is assigned to a bool variable named: result
6. In main(), call a function named: showResult
Pass the bool variable, result, to the function.
If result
true, the function outputs: Valid
==
Otherwise, the function outputs: Invalid
Transcribed Image Text:HW_7a-1c Write a program that prompts the user to enter an ID and Password. The ID and Password the user enters are compared to the ID and Password in a file. If the user's ID and Password match the ones on file, VALID should display on the screen. Otherwise, INVALID should display. 1. In your project, create a new text file named: login.txt A File Edit View Project Build 3 -* 2- Source.cpp Enter an ID and Password, like this: tommy 2 12345 2. Use these 3 functions in this program: getLogin, validateLogin and showResult 3. In main(), declare 2 string variables: id and pw 4. In main(), call a function named: getLogin A void function. In the function, the user is prompted to enter an ID and Password (see output). /* OUTPUT Enter your ID : tommy User is asked for an ID and PW in the getLogin function. Enter your PW 12345 Valid. Valid or Invalid is displayed in the showResult function. * / 5. Then, in main(), call a function named: validateLogin The function returns a bool value (true or false). Pass the user's id and pw to the function. In the function, open the login.txt file. Read in the lID and PW in the file into two string variables declared in the function. Name the two variables: filelD and filePW Still in the function, compare the filelD and filePW to the id and pw that were passed from main(). If they are the same, the function returns true. Otherwise, false is returned. The bool value returned to main is assigned to a bool variable named: result 6. In main(), call a function named: showResult Pass the bool variable, result, to the function. If result true, the function outputs: Valid == Otherwise, the function outputs: Invalid
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education