C++ :: Write Program That Prompts User To Enter Item Number
Jun 27, 2013
Write a program that prompts the user to enter an item#, the program should determine if the item is in the file and print the price of the corresponding item. If the item is not in the file an error message should be printed.
All I have so far is
string item_no=0;
cout<<"Enter a item#";
getline(cin,item_no);
if stream openData;
I need to finish the rest in pseudo code
View 2 Replies
ADVERTISEMENT
Nov 8, 2013
Write a program that prompts the user to enter an integer and then displays that integer as a product of its primes and if it is a prime then it should say so? Above is the question I have been given
#include <iostream>
#include <vector>
using namespace std;
int main () {
int num, result;
cout << "Enter A Number " << endl;
system ("pause");
return 0;
}
This is what I have so far, do I have to use a for loop, a while loop or a do loop,
View 7 Replies
View Related
Oct 8, 2014
Here is the whole code:
#include <iostream>
#include <ctime>
#include <cstdlib>
//This program prompts the user to select a number between 2 and 12
//computer throws two dices
//player win if selected number matches the sum of the two dices thrown by computer
[Code] .....
View 6 Replies
View Related
Jan 21, 2014
Write a program that asks the user to enter a student’s grades on four exams. The program should display the four grades and the average of the four grades,rounded to the nearest tenth. To add the grades, use a variable called total_grade, which you should initialize to zero.As the program prompts for and obtains each grade, add the grade to total_grade using the += operator.
View 3 Replies
View Related
Nov 3, 2013
I need to write a program that will allow the user to enter a number "n" and the program tell you that the nth prime number is .....
EXAMPLE
user enters 55
printf("The 55th prime number is %i", variable");
View 1 Replies
View Related
Mar 23, 2014
Write a C++ program that asks the user to enter an even number only. If the user enters an odd number the program should use input validation to ask the user to enter another number.
- The user can enter as many numbers as he wants
- The program should also keep a count of how many numbers entered and display how many odd and even numbers entered.
View 1 Replies
View Related
Sep 23, 2013
I'm making a program that prompts a user for an int value. The value input by the user must be a multiple of 16. If it is not, I must return an error message.
View 5 Replies
View Related
Feb 21, 2014
I'm trying to create a program that allows the user to enter an unknown number of income and expense amounts. The program has to us see a while loop and display the income total, expense total, and total profit or loss. I've got it really close, but I'm doing the loop wrong. It counts the sentinel value (-1) towards the total, instead of just ending like it is supposed to.
#include <iostream>
using namespace std;
int main() {
//declare variables
double incomeInput;
double expenseInput;
double incomeTotal=0;
double expenseTotal=0;
[code]....
View 5 Replies
View Related
Feb 10, 2014
Implement a class Person with two fields name and age, and a class Car with three fields:
The model
A pointer to the owner (a Person*)
A pointer to the driver (also a Person*)
Write a program that prompts the user to specify people and cars. Store them in a vector<Person*> and a vector<Car*>. Traverse the vector of Person objects and increment their ages by one year. Traverse the vector of cars and print out the car model, owner’s name and age, and driver’s name and age.
#include <iostream>
#include <vector>
#include <conio.h>
#include <string>
using namespace std;
class Person {
[Code] ....
View 7 Replies
View Related
Feb 24, 2015
I need to write a program that prompts the user for 10 grades and then find the average. I have that part but I need to average to not include -1. How can I tell the program to not calculate -1 into the average.
#include <iostream>
using namespace std;
int main() {
//Declare variables
float grade[10]; // 10 array slots
int count;
float total = 0;
double average;
[code].....
View 1 Replies
View Related
May 2, 2014
So I need to write a program which tells the user if the number they input is prime or not. I have done so and included the code below. My problem is that I need to allow the user to input if they want to enter another number after the first one using y or n and I am having trouble figure it out.
#include <cstdlib>
#include <iostream>
using namespace std;
[Code].....
View 5 Replies
View Related
Sep 27, 2014
I have an assignment in which i must create a program which prompts for user input of current and birth date, which will compare said dates and output if its your birthday or not. I've completed a large portion of it, but cannot figure out how to get the user input of month as an integer such a 2 into February.
#include <iostream>
using namespace std;
class DayOfYear {
public:
void input();
[code]....
View 1 Replies
View Related
Jun 14, 2013
i'm trying to write a calculator. the user will enter the terms and they will be stored in arrays. i will be storing those terms in string arrays and then later turn them to double to work with them. but the user should be able to enter terms like sin(252) and the program should be able to recognize it and calculate it.
View 4 Replies
View Related
Aug 22, 2014
I am trying to write up something to have a user to enter a four digit number. Only four digits, Ex: 0001, 0116, or 9999. There is no getting around the selection 0001 or 0002. I understand if not done correctly, the first three 0's will be ignored.
I've been just playing around with what I have below but I just don't remember how to do it nor can I find a good example online to figure it out. I know it is not correct just typing to try to remember. I am aware that it is gibberish right now, this is just me brainstorming.
int number;
cout<<("Please enter the four digit number(Ex: 0001):
");
cin>> setw(2) >> number;
cout<<)"Please enter four digit date. Two digits for month and two digits for year:
");
cin>> date;
if (number< || number > 30)
cout << "Invalid choice. Try again." << endl;
cin.clear();
View 2 Replies
View Related
Mar 22, 2013
I'm stuck because I can make the calculator just find but the user will have to press enter after every number, what is s solution to this?
#include <iostream>
#include <string>
using namespace std;
int a = 1, b, c;
string symbol;
int multiplyFunction();
[Code] .....
View 6 Replies
View Related
Dec 4, 2014
I don't know how to ask the user to enter the date in this format (DD/MM/YY) and ISBN number with hyphens.
After user enter date and ISBN number, it should look like this:
Date: 5/24/12
ISBN: 0-000-12345-0
#include <iostream>
#include <string>
using namespace std;
int main() {
string date;//MM/DD/YY Format
[Code] ....
View 7 Replies
View Related
Jul 2, 2013
I am trying to make a program that will allow a user to enter their name, from this point, three options should be present for the user to choose, then from that point, two more options should be present. I have if else statements in a switch case and I get the "undeclared" error for the a in the first " if(specificage == a) ".
NOTE: I use Code::Blocks.
Here is the code:
Code:
#include <stdio.h>
#include <string.h>
int main(){
char name[50];
char ageclass[50];
char specificage[50];
[Code] ....
View 3 Replies
View Related
Feb 11, 2013
B. Circle in a Square Write a C++ program that will ask the user to enter the area of a square. Then the program will display the biggest area of a circle that will fit in a given square. Using math.h library is not allowed.
View 1 Replies
View Related
Jan 30, 2015
-Write a program using while loops that prompts the user for a set of integers.
-Your program will ask for one integer at a time. If the number 0 is entered, the list is complete and your program will output two results: the sum of the even integers and the sum of the odd integers.
-After each integer is entered by the user, your program will print out whether the integer entered by the user is less than, equal to, or greater than the previous integer. Assume for the first integer entered by the user that the “previous integer” was 0.
-Your program must handle a variable number of inputs (in other words, you cannot hard code for the test cases).
This is what I have so far:
#include <iostream>
using namespace std;
int main() {
int a;
int b;
[Code] .....
View 2 Replies
View Related
Mar 24, 2014
the problem that I'm running into is that the compiler skips to the end when I put my initials in //User input > "Initials"
I'm using Microsoft Visual C++ 2010 Express.
Here is the assignment:
Plan and code a program to do the following. You found an exciting summer job for 5 weeks. It pays $15.50 per hour. You will input the number of hours per week that you worked and then compute your total earnings. You must pay taxes of 14%. After paying taxes, you will spend 20% of your money on cloths and 5% on school supplies. After buying clothes and supplies, you will use 25% of the remaining money for savings.
Input
Your 3 initials and the hours for each of the 5 weeks. Use the following numbers of hours for your first test 25, 30, 20, 23, 22.
Calculations
Gross pay is the rate of pay times the sum of all hours you worked. Use CONSTANTS for each of the following rates:
Tax rate 14% of the gross earnings
Clothing 20% of earnings after taxes
School supplies 5% of earnings after taxes
Savings 25% of earnings after taxes and expenses
Output:
Output your initials, total hours worked, gross earnings, taxes, net earnings after taxes, clothing expense, supplies expense, amount going to savings and amount left to spend. Output must be aligned to the right as shown with 2 decimals in all numbers. Sample output:
Initials ABC
Total Hours Worked 120.00
Gross Earnings 1860
Taxes paid 260.40
Net Earnings 1599.60
[code]....
Turn in:Be sure your output file contains user prompts and what was entered by the user. In addition to the results of your program processing. Run with above listed data.
Here is my code
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double Initials, TotalHours, GrossEarn, TaxesPaid;
[code]....
View 6 Replies
View Related
Apr 23, 2014
how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...
View 4 Replies
View Related
Dec 12, 2013
a program that allows the user to enter a statement and outputs statistics; number of vowels, number of constants, percentage of vowels and constants, number of words, number of punctuation characters
View 2 Replies
View Related
Oct 18, 2014
My assignment is : Please use C type strings ( array representation of strings). Write a program that will ask the user to enter a string. It will then regard that string as a worked-on string and allow the user to perform the following editing functions on it:
s – search
i – insert
a – append
d – delete
a – append
d – delete
r – replace
e – exit
s – search
This option will allow the user to search for a specified string in the worked-on string. If the string is
found, it will display the starting index (position) of the searched string in the worked-on string.
here is what i have so far.
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char a_string[80];
[Code] .....
View 4 Replies
View Related
Oct 12, 2013
You enter decimal number into the program and what base you want. The integer part of the decimal is being handled fine, but the decimal is not.
For example, I enter 15.6847 and base 10, which means I'm going from base 10 to base 10. It spits out 68469999999999 for the decimal part. (Do not worry about the first block of numbers. The second block seperated from the first by a space is where the decimal will appear in order.)
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int baseConverter(int, int, int *, int *);
[Code] ....
View 2 Replies
View Related
Oct 5, 2013
Okay, so my assignment for my C class is to generate a program that will allow the user to enter data for a stock and calculate the amount of stocks that ended up being positive, negative, and neutral.I tried to do this using one stock, here is my code;
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
Code:
void main()
{
float Neg;
float incst;
float shrs;
float bpps;
float crnt;
float crntcst;
float yrfes;
float pft;
float tpft;
}
[code]....
View 6 Replies
View Related
Apr 9, 2014
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */
[Code]...
It says the error is on line 23
View 6 Replies
View Related