C :: Generate A Program That Will Allow User To Enter Data For A Stock And Calculate Amount Of Stocks

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


ADVERTISEMENT

C :: Program That Allow To Enter Certain Amount Of Values

Sep 29, 2014

How to write a code that will let me input how many variables I want.

Write a program that will enable you to enter a certain amount of values

Eg. 4

And then add the corresponding integers. Ex.

Choice: 4 12 34 56 78

The sum of the integers is: 180.

View 4 Replies View Related

C++ :: Create A Program That Will Let User Input Amount In Form?

Jan 4, 2014

Figure this out using [TURBO C]

Create a program that will let the user input an amount in the form (367). The Program should determine the no. of coins for each dominations : 50,25,10,5,1. (using Turbo C)

View 7 Replies View Related

C :: Program That Will Allow A User To Enter Their Name

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

C++ :: Program That Will Ask User To Enter Area Of Square?

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

C++ :: Program That Asks User To Enter Even Number Only

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

C++ :: Program Which Allows A User To Enter Input For A Time Interval

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

C++ :: Program That Allows User To Enter Statement And Outputs Statistics?

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

C++ :: Write A Program That Prompts The User To Enter Integer?

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

C++ :: Variadic Templates - Enter Unlimited Amount Of Types In Function

Feb 25, 2013

I'm looking for a way to enter an unlimited amount of types in the <> part of a template function, I found Variadic templates but I'm not sure if it can do it, all the examples I've found are similar to the C argument list and don't use the <> part of the template at all.

I tried this, but the overload is ambiguous?

#include <iostream>
#include <typeinfo>
template<typename T>
void stuff() {
std::cout << typeid(T).name() << "

[Code] ....

View 2 Replies View Related

C++ :: Stock Market Program - Sorting With Vectors

Sep 29, 2013

I'm writing a program of a stock market where i read from a file and sort with symbols and percent gain/loss. I have completed sorting with symbols but having trouble establishing the percent gain loss. First i designed and implemented the stock object. call the class stockType. main components of a stock are the stock symbol, stock price and number of shares. Second we have to create a list of stock objects. call the class to implement a list of stock objects stockListType. To store the list of stocks, i declared a vector and called the component type of this vector stockType. Because the company requires me to produce the list ordered by percent gain/loss, i need to sort the stock list by this component.

However, i'm not to physically sort the list by component percent gain/loss; instead i should provide a logic ordering with respect to this component. To do so i added a data member, a vector to hold the indices of the stock list ordered by the component percent gain/loss and i called this array indexByGain. I am going to use the array indexByGain to print the list. The elements of the array indexByGain will tell which component of the stock list to print next. I have trouble going about how to implement the function sortStockGain(). Below is my entire code and the txt file. I have sort symbols working but dont know how to implement the sort by gain.

Below is my entire code:

[#ifndef STOCKTYPE_H
#define STOCKTYPE_H

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
class stockType

[Code] ....

View 4 Replies View Related

C++ :: Write Program That Asks User To Enter Student Grades?

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

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 View Related

C++ :: C Type Strings - Program To Ask User To Enter A String And Perform Functions

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

C/C++ :: Creating Program That Allows User To Enter Unknown Number Of Income / Expense Amounts

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

C++ :: User Input Data About Percentages To Calculate Final Grade - Addition Error?

Sep 15, 2014

I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in

Assignments = .3
Midterm1 = .3
Midterm2 = .3
Finals = .1

the program doesn't recognize that they add up to 1. Heres the relevant portion of my code [URL] ....

Here's some examples of how it works [URL] ....

And heres what i dont understand [URL] ....

Why is it saying .3 + .3 + .3 + .1 != 1 when .1 + .3 + .3 + .3 == 1?

View 1 Replies View Related

C/C++ :: Program That Calculate PI Based On User Input For Accuracy?

May 24, 2014

I am trying to create a program that will calculate pi based on a user input for accuracy. If the user input .3 then when the leibniz infinite sum value at a particular i becomes less then the input of .3 then the loop will exit.

I have looked at a number of examples on the internet but I feel lost. I have put together working code that will infinitely output sums but I need the loop to stop when the sum value is less then the accuracy value.

My question is what is wrong with my while loop, why will it only give me infinite summations? How do I make it so that the loop will exit when my accuracy input is greater then the sum?

int main () {
double accuracy;
cout<<"Give an accurate number." << flush;//looks nice
cin>>accuracy;
int d;//initialize denominator
double pi = 0.0;
while(accuracy < d){

[Code]...

View 8 Replies View Related

Visual C++ :: Program That Take Input From A User And Calculate It In A Do While Loop

May 15, 2013

I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.

#include <iostream>
#include <cmath>
using namespace std;
double original_cost;
double discount;
double tax;
double total;
char answer;

[Code]...

View 2 Replies View Related

C++ :: Calculate Simple Interest Of Given Loan Amount And Duration In Years

Jan 25, 2013

Your objective is to write a program that calculates the simple interest for a given loan amount and duration (in years).

Formula:

Simple interest = loan amount X interest rate X number of years
Assume interest rate is a constant 6% per year.

Specifically, your program will:
1. Output descriptive header
2. Prompt and read any customer’s first name, middle initial, and last name individually
3. Prompt and read the principal/loan amount
4. Prompt and read the duration of the loan in years
5. Calculate the interest
6. Output:
a. Customer full name
b. Principal/loan amount
c. Duration of loan
d. Interest rate
e. Interest on loan
f. Principal and interest due at end of term

OK SO THIS IS MY PROGRAM SO FAR. As you can see i got it all but i am so confused with as to for loan amount and duration of year, if i should use float or double to declare it?

i need to finish this assignment by calculating the simple interest and i dont know how or where to begin.

int main(){
system("color f0");
string firstName;
string middleInitial;
string lastName;
cout<<"Please enter your First Name: ";

[Code]...

View 1 Replies View Related

C++ :: Painting Company - Calculate Amount Of Paint Required For Every Contract

Dec 15, 2014

You work for a painting company. Your job is to calculate the amount of paint needed for every contract assigned to the company. This time, you need to paint an outside wall. The dimensions of the wall are 5 X 7m. The window is a circle with the radius of 1m. Write a program that would calculate the following:

The amount of paint needed knowing that you need 1 gallon per 10 square meters. The amount of time to complete the job knowing that it takes 1 hour per 10 square meters to prepare the surface, 5 minute per square meter to pant it and 5 minute per square meter to clean up the area.

View 8 Replies View Related

C++ :: Calculate Fewest Number Of Each Denomination Needed To Pay A Bill Of Amount Total

Mar 5, 2013

Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.

View 1 Replies View Related

Visual C++ :: Calculate Amount Paid To Employee Based On Hours Worked And Rate Per Hour

Oct 8, 2013

Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.

I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.

Code:
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
using namespace std;
int main(void) {
char *empname, *test, *final_output;

[Code] .....

View 7 Replies View Related

C :: Program That Allow User To Enter A Number N And Print Nth Prime Number

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

C++ :: Bubble Sorting With User Defined Amount Of Elements

Feb 25, 2014

I am writing some code to bubble sort a list of randoms numbers, 10 at the moment. I want to be able to user input the amount of elements that would be sorted. I think i'd have to use vector instead of arrays, but unsure how to do this. Or, how to be able to change the size of the array.

#include <iostream>
using namespace std;
#define SIZE 10

float numbers[SIZE];
int move_n;

[Code] ....

View 1 Replies View Related

C# :: (Grid) Stop User From Clicking Past A Certain Amount Of Block

May 21, 2014

0
down vote
favorite

So, I'm attempting to create a grid on the screen, and to do so, I've implemented a multidimensional array of Rectangles. When the program starts, I use a for loop to increase the x and y coordinates to form the grid.

public Form1() {
InitializeComponent();
for (int x = 0; x < 12; x++) {
for (int y = 0; y < 12; y++) {

[Code] ....

My issue is trying to figure out when the user has clicked on a rectangle, and furthermore, which rectangle in the array that he/she has clicked on. As I will change the border to red when given the correct rectangle.

I'm using Visual Studio 2008, and here is my code so far.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

[Code] .....

I'm making this into a real game, with classes and all.

View 7 Replies View Related

C++ :: Sending Variable Amount Of Data Over Winsock?

Oct 31, 2013

Client:

Code: ....
string cmd = "dir c:filequeue > ";
string outputFilePath;
outputFilePath.append(getTempPath());
outputFilePath.append(" est.txt");
cmd.append(outputFilePath);
system(cmd.c_str()); // dir c:filequeue > %temp% est.txt
string content = get_file_contents(outputFilePath.c_str());

send(s, content.c_str(), content.length(), 0); I'm executing the "dir" command to get a listing of Folders/files of one Folder. Then I read the Output of the file and send it over winsock to the Server.

Now, the Problem is, I don't know how I can handle the recv properly, cause I have to set the buffer size without knowing, how much data is actually transfered. Sometimes maybe no files are in c:filequeue, sometimes a 100k.

So I tried to make recv as a Loop:

Server:

Code: ...

while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf); //please no discussion about gets, I will Change this later ;)
if (strcmp(buf, "ls") == 0){
send(connectedSocket, "LIST", 4, 0);

[Code] .....

now it works, but as the recv blocks, it will never leave the Loop, even when the Transfer is finished.What should I do?

I believe I could make unblocking sockets, but that's a bit complicated. Isn't there an easier solution, with malloc'ing the buffer or a Signal when to leave the recv Loop?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved