answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ValentinkaMS [17]
2 years ago
6

Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input.

Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the last name. Hint: Use the to_string() function to convert numerical data to a string.
Computers and Technology
1 answer:
Neko [114]2 years ago
3 0

Answer:

In C++:

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

int main(){

   string lname, fname,stringnum;    int num; string login, pwd;

   cout<<"Last Name: ";    cin>>lname;

   cout<<"First Name: ";    cin>>fname;

   cout<<"Four-digit integer: ";    cin>>num;

   stringnum = to_string(num).substr(0,4);

   stringstream geek(stringnum);    geek>>num;

   num = num%100;

   pwd = to_string(num);

   if(lname.length()<5){ login = lname+fname.substr(0,1);    }

   else{ login = lname.substr(0,5)+fname.substr(0,1);    }

   cout<<"Login Name: "<<login<<endl;

   cout<<"Password: "<<pwd<<endl;

   return 0;

}

Explanation:

This declares all necessary variables

   string lname, fname,stringnum;    int num;     string login, pwd;

This prompts the user for last name

   cout<<"Last Name: ";    cin>>lname;

This prompts the user for first name

   cout<<"First Name: ";    cin>>fname;

This prompts the user for a four digit integer

   cout<<"Four-digit integer: ";    cin>>num;

This converts the input number to string and gets only the first four integer

   stringnum = to_string(num).substr(0,4);

This converts the string back to an integer

   stringstream geek(stringnum);    geek>>num;

This gets the last two of the four digit integer

   num = num%100;

This gets the password of the user

  pwd = to_string(num);

This gets the login name of the user.

This is executed if the length of the first name is less than 5

<em>    if(lname.length()<5){ login = lname+fname.substr(0,1);    }</em>

This is executed if otherwise

<em>    else{ login = lname.substr(0,5)+fname.substr(0,1);    }</em>

This prints the login name

   cout<<"Login Name: "<<login<<endl;

This prints the password

   cout<<"Password: "<<pwd<<endl;

You might be interested in
_______________ is used by a hacker to mask intrusion and obtain administrator permissions to a computer.
Sergeu [11.5K]

Answer:

Rootkit.

Explanation:

Rootkit is a collection of software tools,mostly malicious.These are mostly used by hackers to obtain administrator permission to a computer by masking intrusion.

Root-kit is made from two word Root and kit.Where root refers to the name of privileged account on an operating system that is somewhat like unix and KIT refers to the tools used.

6 0
2 years ago
JAVA
barxatty [35]

Answer:

Answer is in the provided screenshot! This was a lot of fun to make!

Explanation:

We need to create a new Array which has to be the size of amount * original - as we now that we are going to have that many elements. Then we just iterate through all the values of the new array and set them equal to each of the elements in order.

Ignore the code in my main function, this was to print to the terminal the working code - as you can see from the output at the bottom!

5 0
2 years ago
Describe how the process of sampling, RGB pixels, and binary sequences work together to display a digital color image
Rina8888 [55]

Explanation:

Sampling and RBG (red blue green) pixels and also the binary sequences working together such that it display any digitally colored image by allowing the computer system know where the Red Blue Green pixel is going to be placed and also what the opacity would be for that pixel. The combination of these components is what gives you a digital color image.

5 0
2 years ago
Which of the following would be a considered a want rather than a need for most people?
UNO [17]

c. would be the best answer.


3 0
2 years ago
What is the value of x after each of the following statements is encountered in a computer program, if x=1 before the statement
steposvetlana [31]

Answer:

x=2

x=1

x=2

Explanation:

a)

This if statement if (1+2=3) checks if the addition of two numbers 1 and 2 is true. Here the addition of 1 and 2 is 3 which is true. So the condition becomes true.

Since the condition is true x:=x+1 statement is executed. This statement means that the value of x is incremented by 1.

The value of x was 1 before the if statement is reached. So x:=x+1 statement will add 1 to that value of x.

x:=x+1 means x=x+1 which is x=1+1 So x=2

Hence value of x is 2 (x=2) after the execution of x:=x+1

b)

In statement b the value of x will be 1 because both the mathematical operations in the if statement evaluate to false.

which means in b, x:=x+1 will not be executed and value of x remains unchanged i.e x=1

In (c) the value x will be 2 because the condition in the if statement is true. Both mathematical expressions 2+3=5 and 3+4=7 are true. Therefore x:=x+1 will be executed and value of x will be incremented by 1. Hence x=2

5 0
2 years ago
Other questions:
  • What is a typical grace period for a credit card...
    15·2 answers
  • Programming challenge description: Write a program that, given two binary numbers represented as strings, prints their sum in bi
    6·1 answer
  • Develop an EER model for the following situation using the traditional EER notation, the Visio notation, or the subtypes inside
    8·1 answer
  • Juan, a network user, sends an email to you, the IT admin of the network, stating that his account is locked because he has lost
    14·1 answer
  • 3.14 LAB: Simple statistics for Python
    7·1 answer
  • Team A found 342 errors during the software engineering process prior to release. Team B found 184 errors. What additional measu
    12·1 answer
  • Which of the following image file formats uses lossy file compression?
    7·1 answer
  • You are working on a documentation file userNotes.txt with some members of your software development team. Just before the file
    12·1 answer
  • The Coins class was created to hold all your loose change, kind of like a piggy bank! For this exercise, you are going to simula
    15·1 answer
  • A Security team is working with a client to evaluate the security of data and IT functions that are most critical to the operati
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!