Visual C++ :: Creating A Function That Needs To Determine Perfect Scores

Jun 24, 2013

This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:

Code:
// Write a modular program that accepts at least 10 integer test scores from the user and stores them in an array.
// The main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function.
// Input validation: Do not accept scores less than 0 or greater than 100.

#include <iostream>
using namespace std;
int countPerfect(int intArray[], int); // Function prototype

[Code] ....

View 14 Replies


ADVERTISEMENT

Visual C++ :: Determine Type In Function Template

Jul 28, 2013

I want to detect the type in a function template, like this:

template <class myType> myType Function (myType a, myType b) {
//Detect the myType
If (myType is int)

[Code] ......

Is that possible?

View 6 Replies View Related

Visual C++ :: Implementing Classes And Creating Driver Function?

Nov 30, 2012

I'm am having a few issues with this program, they stem from passing the color.h and .cpp into another .h and .cpp, and frankly getting how those two things really fit together.

For this problem, you will design and implement 2 classes and then write a driver function to test these classes. The first will be a C++ class for an abstract data type color with a public enumeration type colorType that has the color values shown in Listing 10.8. Your abstract data type should have an attribute for storing a single value of type colortype and member functions for reading (readColor) and writing (writeColor) a color value as well as setting and accessing it. The function readColor should read a color as a string and store the corresponding color value in the value attribute of a type color object. The function writeColor should display as a string the value stored in the value attribute of a type color object (see Figure 7.5). Modify class circle and the driver function in Listing 10.9 to include and use this class. You'll need to remove the declaration for color in class circle. Test your modified driver function with the new color and circle classes.

The second class will be to design and implement a rectangle class similar to class circle. Be sure to incorporate the new color class you have written and tested in the first part of the programming exercise. Write a client program that asks the user to enter a shape name (circle or rectangle) and then asks the user for the necessary data for an object of that class. The program should create the object and display all its attributes.

The circle class .h and .cpp files as well as the original driver function will be supplied. You are to provide the .h and .cpp files for the new color class and the modified driver function as well as the .h and .cpp files for the rectangle class and the client program that uses all three classes.

color.h

Code:

//color.h
//Color class definition
#include "stdafx.h"
#ifndef COLOR_H

[Code].....

View 3 Replies View Related

C++ :: Read Scores From File And Displays All The Scores

Aug 19, 2014

Okay so suppose that a text file grade.txt contains an unspecified number of scores. How would I program that reads the scores from the file and displays all the scores, their total and average? Scores are stored in the format of one score per line. Im having trouble with the whole #include <fstream> file and how to lay it all out in visual studio.

View 1 Replies View Related

Visual C++ :: Dice Game - Creating Pass By Value Function Reference

Nov 27, 2014

i have a project where i create a dice game, the user rolls 2 dice and the computer roles 2 dice. the player that wins 3 out of 5 rolls wins the game. I have completed the requirements, but i wanted to create a pass by value function for "void Dice()", I'm not too sure how that works?

Code:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
//creating my variables and their values
int compinput;

[Code] .....

View 5 Replies View Related

Visual C++ :: Creating Program To Make Sine Function Without Any Library Other Than Iostream?

Nov 10, 2012

My assignment is to create a C++ Program to find the sine of a number without any library other than iostream by using Taylor Series:

sin (x) = (x/1!) - (x^3/3!) + (x^5/5!) - (x^7/7!) + (x^9/9!) ...... (x^n/n!).

Here is what i have done till now:

#include <iostream>
double fact (int f); //declaration of factorial function
double power(double x, int y); //declaration of power function
double sin(int x); //declaration of sine function
//double cos(int x); //declaration of cosine function
//double tan(int x); //declaration of tangent function

[code]....

View 3 Replies View Related

Visual C++ :: Get Program To Read From File Of 15 Scores?

Dec 10, 2014

I'm trying to get the program to read from a file of 15 scores. 10 are quizzes 5 are exams. I want my program to read from the input file the first name "or" last name and if the user puts a different name, the program Gives off an error screen message

Code:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int NUM_STUDENTS = 20;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;

[code]....

View 14 Replies View Related

C/C++ :: Function To Read Scores Into Array?

Apr 16, 2015

I am currently in a beginner C programming class. I have written most of my code and the problem that I am running into when i compile and run the code. I am able to input more than required scores for input. I think my code is wrong from line 126-136. The program runs fine with no errors. I'm just unable to input the required number of scores allowed.

/*************************************************************************
* A program to calculate grade.
*************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

[Code].....

View 2 Replies View Related

Visual C++ :: Generate Class Average For Entered Test Scores

Jan 14, 2013

Below is the program I have written yet I can't seem to get it to work right.

// Purpose: generate a class average for entered test scores
// Input: # of tests, test scores
// Output: total number of tests, average score of tests

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
//declare variables
short numberOfTests = 0;

[Code] .....

View 6 Replies View Related

Visual C++ :: How To Determine If A Buffer Is Freed Or Not

Dec 9, 2014

I use new to allocate a buffer, as follows:

BYTE *p;
p = new BYTE[20];
...
delete p;

After p is deleted, if I do NOT assign NULL to p, is there a way to determine whether it has already been freed?

View 4 Replies View Related

C++ :: Declaring A Display Function Prototype Only That Displays A Student Test Scores In The Format

Oct 28, 2013

so in declaring a display function prototype only that displays a student test scores in the format (student name tab number of scores tab test scores )

is this right?

#ifndef STUDENTTESTSCORES_H
#define STUDENTTESTSCORES_H
#include <string>
using namespace std;
class StudentTestScores{
private:

[Code]...

and also how do we call the display function if it is in a class from the header file onto the main cpp file.

View 2 Replies View Related

C++ :: Determine If A Function Has Been Defined

Apr 8, 2013

I would like to make a handler for input events, but not be required to define all the functions.For example, if I had

void mouseDown(int button,vec2 pos);
void mouseUp(int button,vec2 pos);
static void mouseStateHandle(int button,int state,int x,int y) {
switch(state){
case DOWN:

[code]....

in the 'mouseStateHandle' function? I don't know enough about C++ to be able to come up with a solution.

View 19 Replies View Related

Visual C++ :: How To Determine Size Of Allocated Buffer

Dec 9, 2014

I use new to allocate a buffer, as follows:

BYTE *p;

p = new BYTE[20];

If I do NOT store the size of the allocated buffer, how to determine the buffer size via p only?

View 6 Replies View Related

Visual C++ :: How To Determine If A Metro App Is Currently Displayed On The Screen

Apr 22, 2014

I'm trying to determine (from my Win32 process) if a Metro (or a Modern UI) app is currently displayed on the screen. I found the IAppVisibility::GetAppVisibilityOnMonitor method that can do just that, and I even found a C++ sample, but my issue is that I'm compiling it with the Visual Studio 2008 that does not have the definitions for the IAppVisibility interface, so the following:

Code:
#include <Shobjidl.h> //Earlier version
IAppVisibility* pAppVis = NULL;
HRESULT hr = CoCreateInstance(CLSID_AppVisibility, NULL, CLSCTX_INPROC_SERVER,
IID_IAppVisibility, (void**) &pAppVis);

Results in a set of errors:

Code:
error C2065: 'IAppVisibility' : undeclared identifier
error C2065: 'IID_IAppVisibility' : undeclared identifier

how to define them?

View 4 Replies View Related

C++ :: Getting Perfect Numbers From Two Values

Oct 22, 2013

Find the perfect numbers between a starting value and a finishing value entered by the users. Display the results to the screen.

I've been told that I need to modify things under the void and the calcdiv in my main () but I can't seem to figure it out. It needs display the perfect numbers between the starting and finishing value. e.g. 28 and 429.

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
void calcdiv(int number) {
for (int i=1;i<=number/2;i++)

[Code] .....

View 3 Replies View Related

C++ :: SFML 2.0 Pixel Perfect Collision

Oct 15, 2013

I have the code and it compiles fine but it doesn't work. (i am using the coding made easy sfml 2.0 tutorials)

Code:

#include <SFML/Graphics.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
class Player {
public:
sf::Sprite player;

[Code] ....

View 18 Replies View Related

Visual C++ :: How To Determine Cross Platform Type During File Save

Nov 10, 2014

I am overriding OnSaveDocument in my MFC document class to strip out the carriage returns when saving my app's document to a UNIX file system but not when the user is saving a file to a Windows file system.

Is there a way to determine if the lpszPathName in OnSaveDocument(LPCTSTR lpszPathName) is a UNIX or Windows file system?

Note, I want to avoid hard coding server names and I want to avoid overriding the FileSave dialog and forcing the user to select Windows or UNIX.

View 6 Replies View Related

C++ :: Function To Determine And Print Prime Numbers

Mar 30, 2013

/* Task: create a function that determines prime number and use it to print out prime numbers from 0-50: */

Function prototype: Should return a `bool` (because it answers a yes/no question) and should take in a single int (to ask whether it's prime).

- An int greater than 2 is prime if it is not divisible by any number between 2 and itself, not including itself.
- Use this function to print out the primes less than 50. Check it against my list:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

#include <iostream>
using namespace std;
int prime(int&x) {
if(x%2==1)

[Code] ....

It is printing out the correct prime numbers but also printing this between each number: 1629974960

View 3 Replies View Related

C++ :: Function To Determine Largest Value In Array And Then Outputs Value And Index

Dec 5, 2013

I'm trying to create a function that determines the largest value in the array and then outputs the value and index. I want to values in the array to be random so I tried using the rand function, although I'm not sure where I'm supposed to put it. My main problem (I think) is outputting the correct values...

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void lastLargestIndex (int numbers[], int arraySize);
int main(int argc, char** argv) {
int number, arraySize = 50;

[Code] ....

View 2 Replies View Related

C++ :: Ask User For A Positive Integer Value And Then Prints Out All Perfect Numbers

Sep 17, 2013

Write a program asks the user for a positive integer value and then prints out all perfect numbers from 1 to that positive integer. I have been trying for some time, i found a way to check if its a perfect number or not but could not find a way to prints out all perfect numbers from 1 to that positive integer. I am here so far.

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n,i=1,sum=0;
cout<<"Enter a number: ";

[Code] ....

View 4 Replies View Related

C/C++ :: Program To Allow User Input And Output Perfect Number

Mar 11, 2014

The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...

#include<iostream>// allows user input/output
#include<conio.h>
#include<fstream>//data file / result file
#include<iomanip>
#include<cmath> // math function
#define in_file "data.txt"
#define out_file "result.txt"

[Code] ....

View 3 Replies View Related

C :: Simple Valid / Invalid Function - Determine Either A URL Address Is Correct Or Not

Jul 13, 2013

I have to write a code which would determine either a URL address is correct or not.

Now, a valid address should look like: "www.something.something.uk".

It has to have 3 dots, 3 w-s in the beginning, and it must end with "uk".

E.g.

Valid addresses:
1. www.jce.ac.uk
2. www.tr2213.oi34.uk

Invalid addresses:
1. www2.jce.ac.uk
2. òæøéàìé - îëììä à÷ãîéú ìäðãñä éøåùìéí - ìéîåãé äðãñä ìúåàø øàùåï
3. www.something.uk

Just to be clear, this criteria mentioned above is not real, just homework

Code:
#include <iostream>
#include <string.h>
using namespace std;
int isValid (char s[])
{
int dots=0;

[Code] ......

It tells me both strings are incorrect but the first 1 is.

View 4 Replies View Related

Visual C++ :: Creating DLL From Program

Jan 15, 2013

I wanna create a DLL from my C++ program. My output of my C++ program is a text file called Centre_Cartouche.txt My output is two text files called brd.txt and sym.txt

At the beginning my program was just a main which contains all development (Main.cpp). Now I created function (in _Cartouche.h and _Cartouche.cpp).

My debugger tell me that the simulation works. But my file Centre_Cartouche.txt is not create.

_Cartouche.cpp_Cartou.hbrd.txtsym.txt

View 1 Replies View Related

Visual C++ :: Creating PHP Array?

Oct 10, 2012

How could I create an array that would in PHP look like this:

PHP Code:

$something['argument1']['argument2'] = "some data to store"; 

View 14 Replies View Related

C/C++ :: Creating / Using GUI With Visual Studio 2013

Jan 24, 2015

How to create/use a graphical interface. Especially since Microsoft has removed Windows Form Application support from Visual Studio 2012 and 2013.

I know that Windows Form Application is still supported with C#, but C# is definitely not an option as the program I am developing is heavily depended on some of C++'s more advanced features not present in C#.

Is there an alternative to Windows Form Application? I would definitely prefer one, as I doubt that some workarounds would work for long. What are common ways to create a GUI application in C++? There certainly must be some ways. In Java one would use something like JFrame.

Crossplattformcompatibility: The program I am creating is a Microsoft Windows program only. So I don't care if it runs on Linux or Mac. It only has to run from Windows 7 onward. So if there are more than one standard ways to create a GUI, I would prefer the one working best for Windows.

By the way, I am using Visual Studio 2013.

View 11 Replies View Related

Visual C++ :: Creating DialogBar With Own Controls (MFC)

May 27, 2013

I'm turning mad with a little problem with Visual Studio 2008 and MFC. I'm working on a project actually and I'm trying to create an SDI Application. Right, now I want to add a dockable DialogBar. Well, the first time I added it with the resource view, I can create the bar without problems. But... I want to add some controls like a couple of ListBox, buttons and so on. The program doesn't allows me to create member variables for these controls. The option appears in grey.

Searching a little, I found that it's mandatory to create a new class derived from CDialogBar and "enhance" it with the Message handler and so on. I've been reading some tutorials and it didn't work for me.

View 14 Replies View Related







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