Question

In: Computer Science

Create a program that will prompt for user information for a Web site. Use a structure...

Create a program that will prompt for user information for a Web site. Use a structure to store the data. The structure will need to include the following items:

  1. First Name - string
  2. Last Name - string
  3. Full Name - string
  4. Birth Date   - int (assume format yyyymmdd)
  5. IsLeasingAutomobile - bool
  6. yearlySalary - float

Create a single structure from the items listed above.

Prompt for all items except "Full Name" and load the input directly into a variable based on this structure .

After the data is loaded, pass the structure by reference to a method called "loadFullName". Inside the "loadFullName" method, load the Full Name data item with a string that is a combination of First Name, space, Last Name. The full name must be converted to uppercase. After the loadFullName has executed, display the value of all the data items in the variable structure.

Review of tasks:

a. Create User Structure
b. Assign a Variable to a User Structure
b. Load the Variable Structure Data
c. Pass the Variable Structured Data to "loadFullName"
d. Display the values of the variable structure.

Note: Input for a boolean var is 0 for false and 1 for true. Adding this line to display once will help display the word false or true in the output.
std::cout << std::boolalpha; 
cout << "is Leasing = " << VarStrucName.isLeasingAutomobile << endl;  // will display true or false - with not 0 being true

Solutions

Expert Solution

#include <iostream>
#include <cstring>
#include <algorithm> 
using namespace std;

struct User
{
    string FirstName;
    string LastName;
    string FullName;
    int BirthDate;
  bool IsLeasingAutomobile;
  float yearlySalary;
};
void loadFullName(struct User *u)
{
    int toupper ( int c );
      cout << "First Name : " << u->FirstName << endl;
      cout << "Last Name : " << u->LastName << endl;
      cout << "Full Name: ";
      std::string data = u->FirstName + ' '+ u->LastName;

std::for_each(data.begin(), data.end(), [](char & c){
    c = ::toupper(c);
});
cout<<data<< endl;
      cout << "Birth Date: " << u->BirthDate << endl;
      cout << "Is Leasing Automobile: " ;
      if( u->IsLeasingAutomobile == 0) 
      {
        cout<<"No"<< endl;
    }
        else
        {
           cout<<"Yes"<< endl;  
        }

      cout << "yearly Salary : " << u->yearlySalary << endl;
      
}

int main(){
      struct User us;
      us.FirstName="Dhiya";
      us.LastName="n";
      us.BirthDate=19880412;
      us.IsLeasingAutomobile=1;
      us.yearlySalary=50000.77;
    loadFullName(&us);
    return 0;

}

Related Solutions

Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
The program will first prompt the user for a range of numbers. Then the game will...
The program will first prompt the user for a range of numbers. Then the game will generate a random number in that range. The program will then allow the user to guess 3 times. Each time the person takes a guess, if it is not the number then the game should tell them to guess higher or lower. They only get 3 guesses. If they have not guessed the number in three tries then the game should tell them the...
IN C This assignment is to write a program that will prompt the user to enter...
IN C This assignment is to write a program that will prompt the user to enter a character, e.g., a percent sign (%), and then the number of percent signs (%) they want on a line. Your program should first read a character from the keyboard, excluding whitespaces; and then print a message indicating that the number must be in the range 1 to 79 (including both ends) if the user enters a number outside of that range. Your program...
Please use markup language HTML5 please. For this homework assignment, you will create a Web site...
Please use markup language HTML5 please. For this homework assignment, you will create a Web site made up of three different pages and links between those pages Index.htm The Web pages in a site should have a similar look-and-feel. For this site, you should create a simple menu as follows: Create a horizontal line across the very top and bottom of the page. Also on the home (Index) page, create links to the other two pages. The links should appear...
Prompt the user for their name, get and store the user input. Prompt the user for...
Prompt the user for their name, get and store the user input. Prompt the user for their age, get and store the user input. We will assume that the user will enter a positive integer and will do no error checking for valid input. Determine and store a movie ticket price based on the user's age. If their age is 12 or under, the ticket price is $5. If their age is between 13 and 64, inclusive, the ticket price...
Create a function named getCreds with no parameters that will prompt the user for their username...
Create a function named getCreds with no parameters that will prompt the user for their username and password. This function should return a dictionary called userInfo that looks like the dictionaries below: # Administrator accounts list adminList = [ { "username": "DaBigBoss", "password": "DaBest" }, { "username": "root", "password": "toor" } ] Create a function named checkLogin with two parameters: the userInfo and the adminList. The function should check the credentials to see if they are contained within the admin...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT