Compiler Error - expected primary-expression before ...

Hi, I've searched the forums but it seems that the answer to this problem depends on a lot of factors. I am kinda new to programming so if you could help me out, I would appreciate it.

This simple program calculates the cast time of skills of a game called Ragnarok Online.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Cast Time Calculator
#include <iostream>
#include <cmath>
using namespace std;

float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed);
float computeReduction(float castTime, int base) ;
void display (int base, float castTime, float reduction);


// This will prompt the user for DEX, INT, Variable Cast Time Reduction (in %), Base Cast Time and Fixed Cast Time Redution (highest modifier)
int main ()
{

   // declaration of variables
   int dexterity, intelligence, variable, base, fixed;
   float castTime, reduction;  

   // Prompt
   cout << "Please insert DEX: ";
   cin >> dexterity;

   cout << "\nPlease insert INT: ";
   cin >> intelligence;

   cout << "\nPlease insert Variable Cast Time Reduction (in %): ";
   cin >> variable;

   cout << "\nPlease insert Base Cast Time: ";
   cin >> base;

   cout << "\nPlease insert highest Fixed Cast Time Reduction: ";
   cin >> fixed;

   // calculate the total cast time
   castTime = computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed);

   // calculate the reduction in %
   reduction = computeReduction(float castTime, int base);

   // display table with results
   display(int base, float castTime, float reduction);

  return 0;
}


// calculates the cast time reduction with the following formula:
// castTime = [(1 - SQRT((DEX * 2 + INT) / 530)) * (1 - sum_castReduction/100%) * baseCast * 0.8] + [(1 - max_fixedReduction/100%) * baseCast * 0.2]

float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed)
{
   float castTime = 0;

   castTime = ((1 - sqrt (((dexterity * 2) +intelligence) / 530)) * (1 - (variable / 100)) * base * 0.8) + ((1 - (fixed / 100)) * base * 0.2);

   return castTime;
}


// reduction = 1- (castTime / base )
float computeReduction(float castTime, int base)
{
   float reduction = 0;
   reduction = (1- (castTime / base)) * 100;
   return reduction;
}



// displays the Base time, adjusted base time and reduction %
void display (int base, float castTime, float reduction)
{
cout << "\nBASE TIME\tCAST TIME\tREDUCTION\n";
cout << base << " seconds" << '\t' << castTime << " seconds\t" << reduction << " %\n";
}


Compiler error:
1
2
3
4
5
6
7
8
9
10
35 CastTimeCalculator.cpp expected primary-expression before "int" 
35 CastTimeCalculator.cpp expected primary-expression before "int" 
35 CastTimeCalculator.cpp expected primary-expression before "int" 
35 CastTimeCalculator.cpp expected primary-expression before "int" 
35 CastTimeCalculator.cpp expected primary-expression before "int" 
38 CastTimeCalculator.cpp expected primary-expression before "float" 
38 CastTimeCalculator.cpp expected primary-expression before "int" 
41 CastTimeCalculator.cpp expected primary-expression before "int" 
41 CastTimeCalculator.cpp expected primary-expression before "float" 
41 CastTimeCalculator.cpp expected primary-expression before "float" 



Duoas wrote:

Start here:
http://www.cplusplus.com/doc/tutorial/functions/

Good luck!


I was about to say the same... he should make global variables with the int's inside those kinda wird functions, AND not declare them has local like he did there... i could fix the whole code but imma go to sleep....
sleep...

1
2
3
4
5
6
7
int dormir ();

int main (){dormir ();}
int dormir ()
{
    _sleep(More_Than_8_Hours)
}


Oh and Duoas you should open this code everytime you turn your computer on:
1
2
3
4
5
6
7
8
#include <iostrean>
using namespace std;
int main ()
{
   _sleep(1000);
   cout << "\nYou are the KING of PROGRAMMING LANGUAGES\n" << "With care: mpruisu and all others whom you have helped... we love you XD";
   main ();
}


Nah im just kidding but still we love you for your contributions ^_^ i guess ill help people out too when i learn more XD
Last edited on
Duoas thx for the link, but I still wasn't able to find my error.
=/
ah, I think that I found my problem. Pretty lame mistake!
I shouldn't have inserted the variable type when calling the functions...
@mpruisu

He doesn't need globals...
Please don't post code that calls main() directly -- that's not a kosher thing to do (because it could do evil things to you).

@Tier

Good job!
Topic archived. No new replies allowed.