|
Alright i have to write this code that is supposed to calculate the gardes of 10 students and output the highest average abd the student Identification number of the person with the highest average.I am stuck and so is my whole class so please help this is what i ahve so far.Please someone save my life
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
char grade(int id, int t1, int t2);//function prototype
// This is the entry point for this application
int _tmain(void)
{
//declaration
char grade;
int t1,t2,tot,avg,max,high_avg_id,id,i;
max=0;
//Processing phase
for (i=1;i<=10;i++)
{
Console::WriteLine(S"Please enter your Student Id: ");
id = Int32::Parse(Console::Readline());
Console::WriteLine(S"Please enter Test one score: ");
t1 = Int32::Parse(Console::ReadLine());
Console::WriteLine(S"Please enter Test two score: ");
t2 = Int32::Parse(Console::ReadLine());
tot = t1 + t2;
avg = tot/2;
if (max < avg)
{
max = avg;
high_avg_id = id;
}
if (avg >= 90)
grade = 'A';
else
if (avg >= 80)
grade = 'B';
else
if (avg >= 70)
grade = 'C';
else
if (avg >= 60)
grade = 'D';
else
grade = 'F';
}
return 0
}
char grade
|
|
|
|
|
// Written By Baiju Max
//EMail:- Baijumax@gmail.com,baijumax@yahoo.com
hi man,
enjoy coding .see below solution for u r problem.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
int _tmain(void)
{
int nMark1(0),nMark2(0),nStudentID(0),nCurrentStudentID(0);
float flAvg(0),flMaxAvg(0);
String* strGrade = new String("No Grade");
//Read The Input From The User
for ( int iIndex = 0 ; iIndex < 2 ; iIndex ++ )
{
Console::Write(S"Pl's Enter The Student ID:");
nCurrentStudentID = Int32::Parse(Console::ReadLine());
Console::Write(S"Enter The Test One Score:") ;
nMark1 = Int32::Parse(Console::ReadLine());
Console::Write(S"Enter The Test One Score:") ;
nMark2 = Int32::Parse(Console::ReadLine());
//Now Caculate Avg
flAvg = (float) (nMark1 + nMark2 )/ 2 ;
if( flMaxAvg < flAvg )
{
flMaxAvg = flAvg;
nStudentID = nCurrentStudentID;
// Now Calculate The Grade
if ( flMaxAvg >= 50 && flMaxAvg < 60 ) //D- Grade 50-59
{ strGrade = "D" ;}
else if ( flMaxAvg >= 60 && flMaxAvg < 70 ) // C- Grade 60-69
{ strGrade = "C" ;}
else if ( flMaxAvg >= 70 && flMaxAvg < 80 ) // B- Grade 70-79
{ strGrade = "B" ;}
else if ( flMaxAvg >= 80 && flMaxAvg < 90 ) // A- Grade 80-89
{ strGrade = "A" ;}
else if ( flMaxAvg >= 90 && flMaxAvg <= 100 ) // S- Grade 90-100
{ strGrade = "A" ;}
else { strGrade = "F" ; }
}
}
Console::Write(S"Student ID Is:" );
Console::Write(nStudentID.ToString());
Console::Write(S"Highest Avg is:");
Console::Write( flMaxAvg.ToString());
Console::Write(S" Grade:");
Console::Write(strGrade);
Console::ReadLine();
return 0;
}
by
baijumax
|
|
|
|
|
your code gave me an error:LNK2019 unresolved external symbol_main refferenced in function_main CRT startup
fatal error LNK1120: 1 unresolved external
|
|
|
|
|
Hi,
I believe problem with your project file. do one thing
start vc.net then select managed c++ Application.
it will create main method;
cut and paste the code inside sample codes main.
by
baijumax;P
|
|
|
|
|
Hey thanks but i was able to resolve the issue.It was a very simple one at that and was totally my mistake.I for got to #include tchar.h
|
|
|
|
|
Don't do peoples homework for them, it doesn't help them in the long run. Also, u and r are letters, they are not words.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi,
Sorry About That.I accept your comment.
by
baijumax
|
|
|
|
|
the following text is:
Note that code is instantiated only for member functions that are called. For class templates, member functions are instantiated only when they are used. This, of course, saves time and space. It has the additional benefit that you can instantiate a class even for those types that cannot perform all the operations of all the member functions, as long as these member functions are not called. As an example, consider a class in which some member functions use the operator < to sort elements. If you refrain from calling these member functions, you can instantiate the class template for types for which operator < is not defined.
what it means?please tell me,thx.
|
|
|
|
|
What bit don't you understand ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I'm using C++ and new to winsock. i'm trying to create a program that sends emails with attachments. FIRST, with WINSOCK, how do i SEND EMAILS and ATTACHMENTS over a server that allowes annoymous emails (eg hotmailmailserver), what information needs to be sent and received, ANY HELP would be nice thanX
yee
|
|
|
|
|
Hi there,
I've created a cli app that allows a user to control windows services. Just a quick question - while trying to "break" the app i noticed that if i performed a pause command on a service that couldnt be paused - the app would just hang. I guess my question is, Is there a way to query the service to find out what control commands it can accept? Any sample code on this would be greatly apprecaited.
Thanks
|
|
|
|
|
i am trying to open this file it won't open, my file name is outdate and i have name and lastname in it. it can't open it that i be able to read throw it.
# include <fstream>
# include <iostream>
# include <fstream>
main()
{
char age;
char name;
const char outfile[20] = "outdata.txt";
ifstream in;
in.open("outdata.txt");
if (!in)
cout << " error in opening: " << endl;
else
cin.get(name);
}
|
|
|
|
|
Is the file in the same folder as your exe ? Also, I can't see your #includes, but the lack of any reference to namespaces makes me thing you've included iostream.h. Don't, this is not valid C++. Use iostream instead ( no .h ). This means you'll need to scope namespace std.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
My purpose is:
- Write a service
- This service must create thread on every process (on every WindowStation)
Problem is:
CreateRemoteThread in MSDN wrote:
Terminal Services isolates each terminal session by design. Therefore,
CreateRemoteThread fails if the target process is in a different session
than the calling process.
If have many users is loging then have many session. I want to
CreateRemoteThread of every session.
My solution is:
- The first, find window station of the process which I must create thread
on it (use WTSEnumerateProcesses)
- The second, use SetProcessWindowStation to assign a window station to the
calling process (is my service). Result my service will operation on the
window station which I must create thread on a process on it.
- Then, use CreateRemoteThread to create thread. Now, CreateRemoteThread is
successful.
Is this solution true ?
Thank in advance.
PTM.
n4_t1
|
|
|
|
|
if somebody could give me this pseudocode"algorith that accepts a positive integer nad then reverses and prints the order of its digits e.g. if input is 9038, the output is 8309"
|
|
|
|
|
I am writing a managed wrapper for an unmanaged class. The unmanaged class is stored in a dll. At the top the of the .cpp file for the managed wrapper i have #using<unmanagedclass.dll> I've also added a reference to this dll using the Add References... option. However, when I compile, the compiler does not recognze my unmanaged class.
Thanks
|
|
|
|
|
hi,
try this one before calling u r unmanaged methods
#pragma UNMANAGED
by
baijumax;P
|
|
|
|
|
|
Hey all,
We have a C++ GUI application built with Trolltech's QT and building with Visual Studio as a Win32 application. If I were to want our application to make the switch to managed code would I be able to do this with the third party (QT) libraries? That is it possible to take existing .libs and 'manage' them in my code? Are there any other caveats?
Thanks,
Daniel
|
|
|
|
|
Can someone out there give suggestions and solutions(console) to a part of my project .. i am pretty new to graphs and C++ .. here is the problem
=--------------------------------------------------------------=
I wanted to implement a graph class with the following functions
addNode - adds a node
addEdge - to connect 2 nodes
countNodes - to return the countof nodes
countEdges - to return count of edges
countPaths(i,j,k) - returns count of number of paths of length k from nodes i to j
displayEdges - display list of edges
can you include the time complexity of each function, and will be glad if you write extra functions to work with my graph exercise
thanking you in advance!!
Bula mai Fiji!
|
|
|
|
|
I have to read a file that has 2 integers in each line. I'm using Visual c++ .net and I read the file like this:
String *l = s->ReadLine();
How can I split the String to have 2 different Strings, each one with one integer?? I know there is a function for String that is called Split but I don´t know how to use it.
Thanks for your help
|
|
|
|
|
Hi,
U Can Use Split Function Like Below. Assume That your string contains 2 integers .seperated by "," or space or any other delimiter.
System::String* YourString = new String("1,2");
System::String* SplitString[]= __gc new String*[2];
SplitString[0]=",";
SplitString = YourString.Split(SplitString[0].ToCharArray(),2); here delimiter ","
by
baiju.km
|
|
|
|
|
I noticed that CodeProject:MaChat - a chat with a browser for LANs, which incidentally is one of the many wealths on this site, can only be compiled in 2002.VS.net. 2003 throws a datatype error. What specifically is different between these IDE versions which would cause this type error.
Just curious
|
|
|
|
|
I have created a new c++ Class Library Project, I've compiled it and dll (x)has been created, now I have a c++.net console app and want to reference x dll. I add the reference and on object browser I can see assembly, namespaces and classes, but when writing using namespace x, I can not reference the classes in the namespace from dll.
I am seeing in the object browser that what is a class in my class library is a public sealed struct (System.ValueType) in the assembly when I reference it.
What am I doing wrong...
|
|
|
|
|
InternetCrackUrl takes an URL_COMPONENTS structure as a parameter, and contained within that structure are various pointers to buffers and associated lengths. One of the options for retrieving information on an URL is to pass a length for a given string as 1, but have the pointer itself pointing to NULL. If one does this, InternetCrackUrl will allocate a buffer for the string in question. My question is, how does one free this memory?
Thanks in advance
|
|
|
|