Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Constructing a chemistry calculator. Need help !

calculator

  • Please log in to reply
1 reply to this topic

#1 Ivan Leong

Ivan Leong

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 26 February 2012 - 02:15 AM

hi guys i am a rookie programmer. I am constructing Arrhenius equation calculator using Microsoft visual C++. The programming language I am currently using is C (Not C++). When i debug the program, 2 error were found. First one says that "Get_input": function does not take 3 argument. The second one sound like "Intellisense : too few argument in function call". Basically i dont know whats the prob and how to solve it.

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
 
 
/* global function that you can use to avoid copy/pasted code */
void get_input(double *frequency_factor, double *rate_constant, double *activation_energy, double *temperature )
{
	printf("Please key in frequency_factor");
	scanf("%lf",frequency_factor);
    printf("Please key in rate constant");
    scanf("%lf", rate_constant);
    printf("Please key in actvation_energy");
    scanf("%lf", activation_energy);
    printf("Please key in temperature");
    scanf("%lf", temperature);
}
 
 
int main (void)
{
    char letter, tmp;
    double rate_constant, frequency_factor, activation_energy, temperature;
     
    puts("This is an Arrhenius Equation calculator\n"
           "k=Ae^(-Ea/RT)\n"
           "A=frequency_factor\n"
           "k=rate_constant\n"
           "Ea=activation_energy\n"
           "R=8.314*10^-3 kJ/mol*k\n"
           "T=temperature\n\n");
 
 
    puts("what do you want to find?\n\n"
         "A)frequency_factor\n"
         "B)rate_constant\n"
         "C)activation_energy\n"
         "D)temperature\n\n");
     
    /* new call here, just for organization's sake. */
     
    tmp = getchar(); 
    getchar(); 
    letter = toupper(tmp); 
 
 
    if (letter=='A') {  
        get_input(&rate_constant, &activation_energy, &temperature);
        frequency_factor=(rate_constant)/pow(2.72,((-activation_energy)/(0.008314)*(temperature)));
        printf("the frequency_factor calculated is %.3f,\n",frequency_factor);
	}
	else if (letter=='B') {
		get_input(&frequency_factor, &activation_energy, &temperature);
		rate_constant=(frequency_factor)*(pow(2.72,(-activation_energy)/(0.008314)*(temperature)));
		printf("the rate_constant calculated is %.3f,\n",rate_constant);
	}
	else if (letter=='C') {
		get_input(&frequency_factor, &rate_constant, &temperature);
		activation_energy=(-0.008314)*(temperature)*(log(rate_constant)/(frequency_factor));
		printf("the activation_energy calculated is %.3f,\n",activation_energy);
	}
	else if (letter=='D') {
		get_input(&frequency_factor, &rate_constant, &activation_energy);
		temperature=(-activation_energy)/((0.00831)*(log(rate_constant)/(frequency_factor)));
		printf("the temperature calculated is %.3f,\n",temperature);
	}
	else 
		printf("You entered the wrong input. Please key in alphabet from A to D only. Thank you !");
    
}

Can anyone teach me how to complete this calculator please. @_@
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 26 February 2012 - 11:02 AM

Well, you've defined get_input to take 4 parameters, but are calling it with three. You have to either remove the unneeded one, or add a fourth to your function call. They HAVE to match.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download