# Ch4_3 - cout<<"Enter whole dollar portion:

This preview shows page 1. Sign up to view the full content.

#include <iostream.h> #include <conio.h> /************************************************** Name: Hung Truong Program: Chapter 4_3: Prices of stock Instructor: Mr. Barkeshli Purpose: Input: Numbers of stock owned, whole dollar portion and fraction portion Output: Value of the user's holding one stock. **************************************************/ bool t=true; char c; int num,dollar,f1,f2; double stockval(int d,int fr1, int fr2); //Calculate stock value of 1 share main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(3); while (t==true) { cout<<"Enter number of stock share owned: ";cin>>num;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout<<"Enter whole dollar portion: ";cin>>dollar; cout<<"Enter two value for fraction portion: ";cin>>f1>>f2; /**********************************************************/ cout<<"Value of the user's holding one stock: "<< num*stockval(dollar,f1,f2)<<endl; /**********************************************************/ cout<<"You want to do it again(Y/N)? ";cin>>c; t=(c=='Y')|(c=='y'); } } double stockval(int d, int fr1, int fr2) { double val; val=d+(static_cast<double>(fr1)/fr2); return val; }...
View Full Document

## This note was uploaded on 03/20/2011 for the course CS 2 taught by Professor Barkeshli during the Spring '11 term at Pasadena City College.

Ask a homework question - tutors are online