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....
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
create a program that will verify a user's login credentials. The program should prompt the user...
create a program that will verify a user's login credentials. The program should prompt the user to enter his/her username and password at the keyboard. Then it should read the data from a data file named "login.txt". The file "login.txt" will contain a list of 3 valid usernames and passwords to verify the login information supplied by a user.  If the username and password entered by the user matches one of the sets read from the file, the program should print...
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...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter payroll information Employee name and create variable for scanner Hours worked Hourly pay rate Federal tax rate State tax rate Declare variable doubles for gross pay, federal, state and total deduction Display payroll statement example: Name of employee Hours worked Hourly pay rate Gross pay which is equal hours worked multiply hourly pay rate Federal withholding which is equal of gross pay multiply federal...
Create a python program that will: prompt a user for a command Command get_data Level 1:...
Create a python program that will: prompt a user for a command Command get_data Level 1: Take one of the commands my_max my_min my_range my_sum mean median mode fib factorize prime Requirements: Your commands should be case-insensitive You should use python lists to store data You should NOT use built-in python math functions, or math libraries to compute these values Tips: Write one function that will convert a string with comma-separated numbers into a python list with the numbers. You...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT