NO

Author Topic: Im doing really bad on this program for class! Can someone help!!!  (Read 4089 times)

dnasty54

  • Guest
/*
* Monthly car payment
*/

#include <stdio.h>  /* printf, scanf definitions */
#include <math.h>

int
   main (void)
{
   double down payment; /* input - down payment */
   double purchase price; /*  input - purchase price */
       double n; /* input - total number of payments */
   double annaual interest rate; /* input - annaual interest rate */
   double total number of payments; /* input - total number of payments */
   double monthly payment; /* output- monthly payment */

   /* get the down payment of car */
   printf("enter down payment price> ");
   scanf('%lf", down payment price);

   /* get purchase price */
   printf(" enter purchase price> ");
   scanf("%lf", purchase price);

   /* get total number of payments */
   printf(" enter total number of payments> ");
   scanf("%lf", n);

   /* get annaual interest rate */
   printf(" enter annaual interest rate> ");
   scanf("%lf", annaual interest rate);

   /* get the total number of payments */
   printf(" the total number of payments> ");
   scanf("%lf", total number of payments);

      /* calculate amount borrowed */
   p = purchase price - down payment;

   /* calculate monthly interest rate */
   I = annaual interest rate /2

   /* calculate monthly car payment */
   monthly car payment = 1-(1+i)^-n/ip

   /* display the monthly car payment */
   printf("\nthe monthly car payment is %.2f", payment);

      return (0)
}


C:\Users\student\Documents\monthly car payment.c(20): error #1040: Unterminated string or char const.
C:\Users\student\Documents\monthly car payment.c(11): error #2001: Syntax error; found 'payment' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(11): error #2048: Undeclared identifier 'payment'.
C:\Users\student\Documents\monthly car payment.c(12): error #2001: Syntax error; found 'price' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(12): error #2048: Undeclared identifier 'price'.
C:\Users\student\Documents\monthly car payment.c(14): error #2001: Syntax error; found 'interest' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(14): error #2048: Undeclared identifier 'interest'.
C:\Users\student\Documents\monthly car payment.c(14): error #2001: Syntax error; found 'rate' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(14): error #2048: Undeclared identifier 'rate'.
C:\Users\student\Documents\monthly car payment.c(15): error #2001: Syntax error; found 'number' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(15): error #2048: Undeclared identifier 'number'.
C:\Users\student\Documents\monthly car payment.c(15): error #2001: Syntax error; found 'of' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(15): error #2048: Undeclared identifier 'of'.
C:\Users\student\Documents\monthly car payment.c(15): error #2001: Syntax error; found 'payments' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(15): error #2048: Undeclared identifier 'payments'.
C:\Users\student\Documents\monthly car payment.c(16): error #2001: Syntax error; found 'payment' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(23): error #2140: Type error in argument 1 to 'scanf'; found 'int' expected 'restrict const char *'.
C:\Users\student\Documents\monthly car payment.c(23): error #2001: Syntax error; found ';' expecting ')'.
C:\Users\student\Documents\monthly car payment.c(24): error #2001: Syntax error; found 'price' expecting ')'.
C:\Users\student\Documents\monthly car payment.c(24): error #2001: Syntax error; found 'price' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(24): error #2001: Syntax error; found ')' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(24): error #2061: Illegal statement termination.
C:\Users\student\Documents\monthly car payment.c(32): error #2001: Syntax error; found 'interest' expecting ')'.
C:\Users\student\Documents\monthly car payment.c(32): error #2001: Syntax error; found 'interest' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(32): error #2001: Syntax error; found 'rate' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(32): error #2001: Syntax error; found ')' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(32): error #2061: Illegal statement termination.
C:\Users\student\Documents\monthly car payment.c(36): error #2001: Syntax error; found 'number' expecting ')'.
C:\Users\student\Documents\monthly car payment.c(36): error #2001: Syntax error; found 'number' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(36): error #2001: Syntax error; found 'of' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(36): error #2001: Syntax error; found 'payments' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(36): error #2001: Syntax error; found ')' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(36): error #2061: Illegal statement termination.
C:\Users\student\Documents\monthly car payment.c(39): error #2048: Undeclared identifier 'p'.
C:\Users\student\Documents\monthly car payment.c(39): error #2001: Syntax error; found 'price' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(39): error #2001: Syntax error; found 'payment' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(42): error #2048: Undeclared identifier 'I'.
C:\Users\student\Documents\monthly car payment.c(42): error #2001: Syntax error; found 'interest' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(42): error #2001: Syntax error; found 'rate' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(45): error #2001: Syntax error; found 'monthly' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(45): error #2001: Syntax error; found 'car' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(45): error #2048: Undeclared identifier 'car'.
C:\Users\student\Documents\monthly car payment.c(45): error #2001: Syntax error; found 'payment' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(45): error #2048: Undeclared identifier 'i'.
C:\Users\student\Documents\monthly car payment.c(45): error #2048: Undeclared identifier 'ip'.
C:\Users\student\Documents\monthly car payment.c(48): error #2168: Operands of ^ have incompatible types 'int' and 'double'.
C:\Users\student\Documents\monthly car payment.c(48): error #2001: Syntax error; found 'printf' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(51): error #2001: Syntax error; found '}' expecting ';'.
C:\Users\student\Documents\monthly car payment.c(45): warning #2114: Local 'car' is not referenced.
C:\Users\student\Documents\monthly car payment.c(16): warning #2114: Local 'monthly' is not referenced.
C:\Users\student\Documents\monthly car payment.c(15): warning #2114: Local 'payments' is not referenced.
C:\Users\student\Documents\monthly car payment.c(15): warning #2114: Local 'of' is not referenced.
C:\Users\student\Documents\monthly car payment.c(15): warning #2114: Local 'number' is not referenced.
C:\Users\student\Documents\monthly car payment.c(14): warning #2114: Local 'rate' is not referenced.
C:\Users\student\Documents\monthly car payment.c(14): warning #2114: Local 'interest' is not referenced.
C:\Users\student\Documents\monthly car payment.c(12): warning #2114: Local 'price' is not referenced.
C:\Users\student\Documents\monthly car payment.c(11): warning #2114: Local 'down' is not referenced.
*** Error code: 1 ***
Done.
 

czerny

  • Guest
Re: Im doing really bad on this program for class! Can someone help!!!
« Reply #1 on: September 30, 2014, 07:53:51 PM »
You can not declare variables with spaces in their name.

Do not use
Code: [Select]
double down payment;
Use
Code: [Select]
double down_payment;for example.

Btw. 'down payment price' is not declared at all and scanf needs the address of the double, not its value!

dnasty54

  • Guest
Re: Im doing really bad on this program for class! Can someone help!!!
« Reply #2 on: September 30, 2014, 08:19:54 PM »
Thank you!!!!!   :) :) :) :) i reposted with those changes made if u wanna take another look at it and help more??

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Im doing really bad on this program for class! Can someone help!!!
« Reply #3 on: October 01, 2014, 12:55:59 AM »
It really helps if you get used to using code tags when posting code (snippets) in the forum (that's the # button/icon just above the message entry box)...  ;)

Ralf