user4039535
user4039535

Reputation:

What is wrong with this? C++

I'm having a go at programming with what I know of C++ for practice. Its a basic calculator for working out things for an MMO that I play.

I want to clear the screen of cmd without using system() commands. However in the function: void clearscreen the first curly brace gives an error in vs 2013 expecting a ;

Also I know that there are probably better ways to do all of this but this is what I currently know and am just getting some practice. I mainly would like to know what is wrong with this but feedback on improving this basic program would also be much appreciated

-Unlogical Logic

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>

using namespace std;

int main()
{
    double timetotal;
    double timeperinv;
    double xptotal;
    double xpitem;
    double amount;
    double perinv;
    double totalinv;
    double costper;
    double costtotal;

    cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
    cout << endl;

    cout << "How much experience do you want to get?" << endl;
    cin >> xptotal;
    cout << endl;

    cout << "How much does it cost per item?" << endl;
    cin >> costper;
    cout << endl;

    cout << "How much experience do you get per item?" << endl;
    cin >> xpitem;
    cout << endl;

    cout << "How many items can you process in one inventory?" << endl;
    cin >> perinv;
    cout << endl;

    cout << "How long does it take to process one inventory of items?" << endl;
    cin >> timeperinv;

    amount   = xptotal / xpitem;
    totalinv = amount / perinv;
    timetotal = totalinv * timeperinv;
    costtotal = amount * costper;

    void ClearScreen()
    {
        cout << string(100, '\n');
    }

    cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
    cout << endl;
    std::cout << std::setprecision(1) << fixed;
    cout << "The amount of items that you will need to process is: \n" << amount << endl;
    cout << endl;

    cout << "The amount of inventories of items that you will need" << endl;
    cout << "to process is \n" << totalinv << endl;
    cout << endl;

    cout << "The total time it will take to complete processing all" << endl;
    cout << "of the items is: \n" << timetotal << endl;
    cout << endl;

    cout << "The total cost of the items will be: \n" << costtotal << endl;
    cout << endl;

    cout << "The total amount of inventories to process is: \n" << totalinv << endl;
    cout << endl;

}

Upvotes: 0

Views: 102

Answers (1)

Paul Evans
Paul Evans

Reputation: 27567

C++ doesn't support inner functions. Simply define ClearScreen before and outside of main().

Upvotes: 1

Related Questions