Question

Q1. Write program calculate the final price of a purchased item using values entered by the...

Q1. Write program calculate the final price of a purchased item using values entered by the user

Hint: you are required to use formatting output for number, currency and percentage.

--------------------[Print Receipt] ------------


Enter the quantity: 6


Enter the unit price: $1.98


Subtotals: $10.14


Tax: $ 0.61 at 6%


Total: $10.75


------------------------------------------------

Q2. Write a program that prompts for and reads the users’ first name and last name, Job title, DOB (date of Birth), and the Email address (separately). Then create and print a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don’t be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each digit does not to be determined separately.

----------------------------[ User details] ---------------------


First name: Adam


Last Name: Hunter


Date of Birth: 20/02/1981


Email Address: [email protected]


Phone number: 235-653-3541


this is a software development question using c++ programing language

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE :

//Q1. Write program calculate the final price of a purchased item using values entered by the user

#include<iostream>   //for using standard I/O operations
#include<iomanip>   //for set precision function
using namespace std;

int main(){
  
//   declaration of variable for taking inputs from the user
   int quantity;
   double price;
   cout<<"---------------------[Print Receipt]-------------------\n";
//   taking the quantity
   cout<<"Enter the quantity: ";
   cin>>quantity;
  
//   prompting for the quantity of the one unit
   cout<<"Enter the unit price: $";
   cin>>price;
  
//   calculating the subtotal
   double subtotal=quantity*price;
   cout<<"Subtotals: $"<<setprecision(4)<<subtotal<<endl;
  
//   calculating the tax at 6%
   double tax=subtotal*6/100;
   cout<<"Tax: $"<<setprecision(2)<<tax<<" at 6%"<<endl;
  
//   calculating the total price after paying the tax at 6%
   double total=subtotal+tax;
   cout<<"Total: $"<<setprecision(4)<<total;
}

CODE SCREENSHOT :

OUTPUT :

CODE :

/*   Q2. Write a program that prompts for and reads the users’ first name and last name,
       Job title, DOB (date of Birth), and the Email address (separately).
       Then create and print a random phone number of the form XXX-XXX-XXXX.
       Include the dashes in the output. Do not let the first three digits contain an 8 or 9
       (but don’t be more restrictive than that),
       and make sure that the second set of three digits is not greater than 742.
*/

#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main(){
//   definfing variables for taking inputs from the user
   string f_name,l_name,email,dob,job_title,phone;
  
//   prompting user for details
   cout<<"Enter the First Name: ";
   cin>>f_name;
   cout<<"Enter Last Name: ";
   cin>>l_name;
   cout<<"Enter the Email Address: ";
   cin>>email;
   cout<<"Enter DOB: ";
   cin>>dob;
   cout<<"Enter Job Title: ";
   cin>>job_title;
  
//   printing the details to the user
   cout<<"-----------------------[ User details]-------------------------"<<endl;
   cout<<"First Name: "<<f_name;
   cout<<"\nLast Name: "<<l_name;
   cout<<"\nDate of Birth: "<<dob;
   cout<<"\nEmail Address: "<<email;
   cout<<"\nPhone Number: ";
  
//   generating a random phone number by using rand() function
// generating a random number between a range is lower+(rand()%(upper-lower+1))

   cout<<rand()%8<<rand()%8<<rand()%8<<"-"<<100+(rand()%(742-100+1))<<"-"<<1000+(rand()%(9999-1000+1));
}

CODE SCREENSHOT :


OUTPUT :


Please provide feedback and comment down if any problem perists.

Add a comment
Know the answer?
Add Answer to:
Q1. Write program calculate the final price of a purchased item using values entered by the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***** TO BE WRITTEN IN JAVA ***** Write an application that creates and prints a random...

    ***** TO BE WRITTEN IN JAVA ***** Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each digit does not have to be...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • Your mission in this programming assignment is to create a Python program that will take an...

    Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents.   Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • User Profiles Write a program that reads in a series of customer information -- including name,...

    User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...

  • Write a program in C++: Using classes, design an online address book to keep track of the names f...

    Write a program in C++: Using classes, design an online address book to keep track of the names first and last, addresses, phone numbers, and dates of birth. The menu driven program should perform the following operations: Load the data into the address book from a file Write the data in the address book to a file Search for a person by last name or phone number (one function to do both) Add a new entry to the address book...

  • CAN SOMEONE PLEASE HELP ME WRITE THIS CODE IN C++, PLEASE HAVE COMMENTS IN THE CODE...

    CAN SOMEONE PLEASE HELP ME WRITE THIS CODE IN C++, PLEASE HAVE COMMENTS IN THE CODE IF POSSIBLE!! General Description: Write a program that allows the user to enter data on their friends list. The list holds a maximum of 10 friends, but may have fewer. Each friend has a name, phone number, and email address. The program first asks the user to enter the number of friends (1-10). You are not required to validate the entry, but you may...

  • Write a code using python to make an Agenda that can store values such as Name,...

    Write a code using python to make an Agenda that can store values such as Name, Address and Phone number of 10 digits Name format First, Last Address Format Street, Number Zip City ST. Country phone format (###) ###-#### This program should give the option of adding a new contact or Display all the contacts you have stored by typing New Contact or Display Contacts

  • 2. Write a program to prepare email address with name of person, email ID. This program...

    2. Write a program to prepare email address with name of person, email ID. This program should collect number of persons with their details menstion in the above. Finally, print all the registerd preson with their details and also print selected particular person's emails. 1. Write a program to prepare departmental store records with item name, number of items. This program should collect number of items with its details menstion in the above. Finally, print all the registerd items with...

  • java; programing language Write a program to calculate the price of a purchase. It should ask...

    java; programing language Write a program to calculate the price of a purchase. It should ask the user to enter the name of the item bought (like sweater, apple, …), number of items bought (4, 5 lbs,…), price per item ($40.50, $1.99 per pound,…), and the sales tax rate (8.35% for example). It should calculate the subtotal (price*number of items), sales tax (subtotal*sales tax), and total price (subtotal+ sales tax). It should print all the information in a receipt form

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT