Hi there,
I am very new to C++ so please bear with my what is clearly terrible work
I am trying to figure out what should be (I think) a simple program that will check a couple of pieces of information and tailor an output based on the input, if you get me
Here is my (albeit amateur) pseudo code:
char scheduled // Whether a particular user is scheduled for work on that date
char logonattempt //whether a particular user has attempted to log on
char entry // whether a particular user has used their security pass to enter the building
Output: Is the user scheduled for work today? (Y/N)
Output: Has the user attempted to log onto their PC? (Y/N)
Output: Has the used gained entry to the building using their security pass? (Y/N)
if
scheduled=1
and
logonattempt=1
and
entry=0
then output "User has attempted to log in but has not passed security to enter building"
elseif
scheduled=0
and
logonattempt=0
and
entry=1
then output "user has entered building but is not scheduled for shift"
elseif
scheduled=0
and
logonattempt=1
and
entry=0
then output "User has attempted to log in but is not scheduled for shift"
elseif
scheduled=0
and
logonattempt=1
and
entry=1
output "User has gained entry and attempted to log in but is not scheduled for shift"
else
"User is fully authorised"
and here is the start of my C++ code, which I'm sure I have done incorrectly anyway and yet do not know where I am going wrong:
#include <iostream>
using namespace std;
main()
{
// variable declarations
char ScheduledIn; // Whether a particular user is scheduled
// for work on that date
char LogonAttempt; // Whether a particular user has attempted
// to log on
char AuthdEntry; // whether a particular user has used their
// security pass to enter the building
// Check if the user was scheduled for work
cout<< "Is the user scheduled for work today? (Y/N)"/n;
cin>> ScheduledIn; // Sets the variable to whatever the user
// inputs
if !(ScheduledIn == ("y" || "n" || "Y" || "N"))
{
cout<< "Please enter a correct value"/n
"Is the user scheduled for work today? (Y/N)"/n;
else
}
// Check if the user has attempted to log in
cout<< "Has the user attempted to log in? (Y/N)"/n;
cin>> LogonAttempt; // sets the variable to whatever the
//user inputs
if !(LogonAttempt == ("y" || "n" || "Y" || "N"))
{
cout<< "Please enter a correct value"/n
"Has the user attempted to log in? (Y/N)"/n;
else
}
// Check if the user gained authorised entry
cout<< "Has the user used their security pass to gain entry? (Y/N)"/n;
cin>> AuthdEntry; // sets the variable to whatever the
//user inputs
if !(AuthdEntry == ("y" || "n" || "Y" || "N"))
{
cout<< "Please enter a correct value"/n
"Has the user used their security pass to gain entry? (Y/N)"/n;
else
}
};
Hopefully my pseudo code will give you a rough idea of what I am trying to do. I was thinking of maybe doing a loopwhile of some sorts for the questions and inputs but do not know how to do this. Then after the input had been given, run an if statement to produce the warnings similar to that in the pseudo code?
I think my if statement goes wrong at the first part, where I'm trying to tell it to discard any other input aside from y, n, Y or N but I can't be sure
Any help would be greatly appreciated, and sorry for the mistakes so far :(
Thanks