please help me.. this will be pass in less than 5 hours... i dont know what is the problem, it seems correct ... but why the error???
it says use of unassigned local variable totcc,mdue, numpayadd

using System;
using System.Collections.Generic;
using System.Text;

namespace ACTIVITY_1_WEEK_5
{
    class Program
    {
        static void Main(string[] args)
        {
                 
            string input = "", cname, cadd, ctn, bname="";
            char ans;
            int choice, numpay;
            int model, cmode;
            double cc, src, tip, lto, sfee, totcc, downpay, numpayadd, mdue, balance;
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkCyan;
      
            do
            {
                
                Console.Clear();
                Console.WriteLine("\n       ********************************************");
               
                Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                Console.WriteLine("\t\t      \"drive ahead\" ");

                Console.WriteLine("\n\t\t     Welcome buyer!");
                
                do
                {
                
                    Console.Write("\n\t Enter your name: ");
                    cname = Console.ReadLine();
                } while (cname == "");
    
                do
                {
                    
                    Console.Write("\n\t Enter your address: ");
                    cadd = Console.ReadLine();
                } while (cadd == "");

                do
                {
                   
                    Console.Write("\n\t Enter your telephone number: ");
                    ctn = Console.ReadLine();
                } while (ctn == "");

            
                do
                {
                    
                    Console.Write("\n\t Select your mode of payment: ");
                    Console.Write("\n\t   [1] CASH");
                    Console.Write("\n\t   [2] FINANCING");
                    Console.Write("\n\t Enter your mode of payment: ");
                    input = Console.ReadLine();
                    cmode = int.Parse(input);
                    if (cmode == 1 || cmode == 2)
                    {
                        if (cmode == 2)
                        {
                            Console.Write("\n\t Enter bank name, branch: ");
                            bname = Console.ReadLine();
                        }

                        break;
                    }

                } while (cmode!=1 && cmode!=2);

                Console.WriteLine("\n       ********************************************");



                Console.Clear();
                
                    Console.WriteLine("\n       ********************************************");

                    Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                    Console.WriteLine("\t\t      \"drive ahead\" ");

                    Console.WriteLine("\n\t   Drive comfortably with our new cars.");
                    Console.WriteLine("\t   [1] ALFA ROMEO");
                    Console.WriteLine("\t   [2] AUDI");
                    Console.WriteLine("\t   [3] BMW");
                    Console.WriteLine("\t   [4] CHERY");
                    Console.WriteLine("\t   [5] CHEVROLET");
                    Console.WriteLine("\t   [6] FORD");
                    Console.WriteLine("\t   [7] HONDA");
                    Console.WriteLine("\t   [8] HYUNDAI");
                    Console.WriteLine("\n\t   * Actual Price found beside the model name");

                    Console.WriteLine("\n       ********************************************");
                    do
                    {
                        Console.Write("\n\t   Select your choice: ");
                        input = Console.ReadLine();
                        choice = int.Parse(input);
                    } while (choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 5 && choice != 6 && choice != 7 && choice != 8);

                    Console.Clear();
                    switch (choice)
                    {
                        

                        //start of car 1
                        case 1:
                            {
                                Console.Clear();
                                Console.WriteLine("\n       ******************************************************");

                                Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                                Console.WriteLine("\t\t      \"drive ahead\" ");

                                Console.WriteLine("\n\t   Drive comfortably with the ALFA ROMEO cars.");
                                Console.WriteLine("\t   [1] ALFA ROMEO 147 (CBU)            191,086.40");
                                Console.WriteLine("\t   [2] ALFA ROMEO 147 GTA (CBU)        321,965.00");



                                Console.WriteLine("\n       ******************************************************");

                                do //start of switching operation among models
                                {
                                    Console.Write("\n\t   Select your choice: ");
                                    input = Console.ReadLine();
                                    model = int.Parse(input);
                                } while (model != 1 && model != 2);

                                Console.Clear();

                                if (model==1) //start of model
                                {
                                   cc = 191096.40;
                                   src = 0.03 * cc;
                                   tip = cc * 0.1;
                                   lto = cc * 0.05;
                                   if (cmode == 1)
                                   {
                                       sfee = cc * 0.05;
                                   }
                                   else //(cmode==2)
                                   {
                                      
                                       sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay!=1 && numpay!=2 && numpay!=3 );

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");
                                        
                                   }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is ALFA ROMEO 147 (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);

                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    
                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}" ,totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname+".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);
                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }
                                else//(model==2)
                                {
                                   cc = 321965;
                                   src = 0.02 * cc;
                                   tip = cc * 0.1;
                                   lto = cc * 0.05;
                                   if (cmode == 1)
                                   {
                                       sfee = cc * 0.05;
                                   }
                                   else //(cmode==2)
                                   {
                                      
                                       sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay!=1 && numpay!=2 && numpay!=3 );

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");
                                        
                                   }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is ALFA ROMEO 147 GTA (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }
                                    
                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}" ,totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname+".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);
                                        
                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }
                                break;
                            } //end of model module







                        //start of car 2
                        case 2:
                            {
                            Console.Clear();
                            Console.WriteLine("\n       ********************************************");

                            Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                            Console.WriteLine("\t\t      \"drive ahead\" ");

                            Console.WriteLine("\n\t   Drive comfortably with the AUDI cars.");
                            Console.WriteLine("\t   [1] AUDI A3 2.0 FSI MULTITRONIC     225,000.00");
                            Console.WriteLine("\t   [2] AUDI A3 2.0T FSI S-TRONIC       225,000.00");
                            Console.WriteLine("\t   [3] AUDI A4 2.0T FSI MULTITRONIC    265,000.00");


                            Console.WriteLine("\n       ********************************************");

                            do //start of switching operation among models
                            {
                                Console.Write("\n\t   Select your choice: ");
                                input = Console.ReadLine();
                                model = int.Parse(input);
                            } while (model != 1 && model != 2 && model !=3);

                            Console.Clear();

                            if (model == 1) //start of model
                            {
                                cc = 225000;
                                src = 0.01 * cc;
                                tip = cc * 0.1;
                                lto = cc * 0.05;
                                if (cmode == 1)
                                {
                                    sfee = cc * 0.05;
                                }
                                else //(cmode==2)
                                {

                                    sfee = cc * 0.08;
                                    do
                                    {
                                        //pre-final display
                                        Console.WriteLine("\n       ***********************************************************************");
                                        Console.Write("\n\t\t Select number of years to pay: ");
                                        Console.Write("\n\t\t   [1] 1 year");
                                        Console.Write("\n\t\t   [2] 2 to 3 years");
                                        Console.Write("\n\t\t   [3] 4 to 5 years");
                                        Console.Write("\n\t\t Enter your choice: ");
                                        input = Console.ReadLine();
                                        numpay = int.Parse(input);
                                    } while (numpay != 1 && numpay != 2 && numpay != 3);

                                    Console.Write("\n\t\t Enter the amount of downpayment: ");
                                    input = Console.ReadLine();
                                    downpay = double.Parse(input);

                                    if (numpay == 1)
                                    {
                                        numpayadd = 0.02 * cc;
                                    }
                                    else if (numpay == 2)
                                    {
                                        numpayadd = 0.06 * cc;
                                    }
                                    else if (numpay == 3)
                                    {
                                        numpayadd = cc * 0.08;
                                    }

                                    totcc = cc + tip + lto + sfee + numpayadd;
                                    balance = totcc - downpay;

                                    if (numpay == 1)
                                    {
                                        mdue = balance / 12;
                                    }
                                    else if (numpay == 2)
                                    {
                                        mdue = balance / 48;
                                    }
                                    else if (numpay == 3)
                                    {
                                        mdue = balance / 60;
                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }

                                Console.Clear(); // final display
                                Console.WriteLine("\n       ***********************************************************************");
                                Console.WriteLine("\n\t\t Dear " + cname + ", your car is AUDI A3 2.0 FSI MULTITRONIC!");
                                Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                if (cmode == 1)
                                {
                                    Console.WriteLine("\t\t Type of payment:        CASH");
                                }
                                else
                                {
                                    Console.WriteLine("\t\t Type of payment:        FINANCING");
                                }

                                Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                if (cmode == 2)
                                {
                                    Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                    Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                }
                                Console.WriteLine("\n       ***********************************************************************");
                            }

                            else if (model == 2) //start of model
                            {
                                cc = 225000;
                                src = 0.04 * cc;
                                tip = cc * 0.1;
                                lto = cc * 0.05;
                                if (cmode == 1)
                                {
                                    sfee = cc * 0.05;
                                }
                                else //(cmode==2)
                                {

                                    sfee = cc * 0.08;
                                    do
                                    {
                                        //pre-final display
                                        Console.WriteLine("\n       ***********************************************************************");
                                        Console.Write("\n\t\t Select number of years to pay: ");
                                        Console.Write("\n\t\t   [1] 1 year");
                                        Console.Write("\n\t\t   [2] 2 to 3 years");
                                        Console.Write("\n\t\t   [3] 4 to 5 years");
                                        Console.Write("\n\t\t Enter your choice: ");
                                        input = Console.ReadLine();
                                        numpay = int.Parse(input);
                                    } while (numpay != 1 && numpay != 2 && numpay != 3);

                                    Console.Write("\n\t\t Enter the amount of downpayment: ");
                                    input = Console.ReadLine();
                                    downpay = double.Parse(input);

                                    if (numpay == 1)
                                    {
                                        numpayadd = 0.02 * cc;
                                    }
                                    else if (numpay == 2)
                                    {
                                        numpayadd = 0.06 * cc;
                                    }
                                    else if (numpay == 3)
                                    {
                                        numpayadd = cc * 0.08;
                                    }

                                    totcc = cc + tip + lto + sfee + numpayadd;
                                    balance = totcc - downpay;

                                    if (numpay == 1)
                                    {
                                        mdue = balance / 12;
                                    }
                                    else if (numpay == 2)
                                    {
                                        mdue = balance / 48;
                                    }
                                    else if (numpay == 3)
                                    {
                                        mdue = balance / 60;
                                    }
                                    Console.WriteLine("\n       ***********************************************************************");

                                }

                                Console.Clear(); // final display
                                Console.WriteLine("\n       ***********************************************************************");
                                Console.WriteLine("\n\t\t Dear " + cname + ", your car is AUDI A3 2.0T FSI S-TRONIC!");
                                Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                if (cmode == 1)
                                {
                                    Console.WriteLine("\t\t Type of payment:        CASH");
                                }
                                else
                                {
                                    Console.WriteLine("\t\t Type of payment:        FINANCING");
                                }

                                Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                if (cmode == 2)
                                {
                                    Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                    Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                }
                                Console.WriteLine("\n       ***********************************************************************");
                            }

                            else//(model==3)
                            {
                                cc = 265000;
                                src = 0.025 * cc;
                                tip = cc * 0.1;
                                lto = cc * 0.05;
                                if (cmode == 1)
                                {
                                    sfee = cc * 0.05;
                                }
                                else //(cmode==2)
                                {

                                    sfee = cc * 0.08;
                                    do
                                    {
                                        //pre-final display
                                        Console.WriteLine("\n       ***********************************************************************");
                                        Console.Write("\n\t\t Select number of years to pay: ");
                                        Console.Write("\n\t\t   [1] 1 year");
                                        Console.Write("\n\t\t   [2] 2 to 3 years");
                                        Console.Write("\n\t\t   [3] 4 to 5 years");
                                        Console.Write("\n\t\t Enter your choice: ");
                                        input = Console.ReadLine();
                                        numpay = int.Parse(input);
                                    } while (numpay != 1 && numpay != 2 && numpay != 3);

                                    Console.Write("\n\t\t Enter the amount of downpayment: ");
                                    input = Console.ReadLine();
                                    downpay = double.Parse(input);

                                    if (numpay == 1)
                                    {
                                        numpayadd = 0.02 * cc;
                                    }
                                    else if (numpay == 2)
                                    {
                                        numpayadd = 0.06 * cc;
                                    }
                                    else if (numpay == 3)
                                    {
                                        numpayadd = cc * 0.08;
                                    }

                                    totcc = cc + tip + lto + sfee + numpayadd;
                                    balance = totcc - downpay;

                                    if (numpay == 1)
                                    {
                                        mdue = balance / 12;
                                    }
                                    else if (numpay == 2)
                                    {
                                        mdue = balance / 48;
                                    }
                                    else if (numpay == 3)
                                    {
                                        mdue = balance / 60;
                                    }
                                    Console.WriteLine("\n       ***********************************************************************");

                                }

                                Console.Clear(); // final display
                                Console.WriteLine("\n       ***********************************************************************");
                                Console.WriteLine("\n\t\t Dear " + cname + ", your car is AUDI A4 2.0T FSI MULTITRONIC!");
                                Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                if (cmode == 1)
                                {
                                    Console.WriteLine("\t\t Type of payment:        CASH");
                                }
                                else
                                {
                                    Console.WriteLine("\t\t Type of payment:        FINANCING");
                                }

                                Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                if (cmode == 2)
                                {
                                    Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                    Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                }
                                Console.WriteLine("\n       ***********************************************************************");
                            }
                            break;
                        } //end of model module






                    //start of car 3
                        case 3:
                            {
                                Console.Clear();
                                Console.WriteLine("\n       ********************************************");

                                Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                                Console.WriteLine("\t\t      \"drive ahead\" ");

                                Console.WriteLine("\n\t   Drive comfortably with the BMW cars.");
                                Console.WriteLine("\t   [1] BMW 116i (CBU)	    168,000.00");
                                Console.WriteLine("\t   [2] BMW 118i (CBU)	    199,900.00");
                                Console.WriteLine("\t   [3] BMW 120i (CBU)	    222,000.00");


                                Console.WriteLine("\n       ********************************************");

                                do //start of switching operation among models
                                {
                                    Console.Write("\n\t   Select your choice: ");
                                    input = Console.ReadLine();
                                    model = int.Parse(input);
                                } while (model != 1 && model != 2 && model != 3);

                                Console.Clear();

                                if (model == 1) //start of model
                                {
                                    cc = 168000;
                                    src = 0.02 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
                                    {

                                        sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay != 1 && numpay != 2 && numpay != 3);

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");

                                    }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is BMW 116i (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }

                                else if (model == 2) //start of model
                                {
                                    cc = 199900;
                                    src = 0.05 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
                                    {

                                        sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay != 1 && numpay != 2 && numpay != 3);

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");

                                    }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is BMW 118i (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }

                                else//(model==3)
                                {
                                    cc = 222000;
                                    src = 0.01 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
                                    {

                                        sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay != 1 && numpay != 2 && numpay != 3);

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");

                                    }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is BMW 120i (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }
                                break;
                            } //end of model module






                        //start of car 4
                        case 4:
                            {
                                Console.Clear();
                                Console.WriteLine("\n       ********************************************");

                                Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                                Console.WriteLine("\t\t      \"drive ahead\" ");

                                Console.WriteLine("\n\t   Drive comfortably with the CHERY cars.");
                                Console.WriteLine("\t   [1] CHERY A160 1.6L (M) (CBU)	    61,888.10");
                                Console.WriteLine("\t   [2] CHERY A160R 1.6L (M) (CBU)	    64,888.10");



                                Console.WriteLine("\n       ********************************************");

                                do //start of switching operation among models
                                {
                                    Console.Write("\n\t   Select your choice: ");
                                    input = Console.ReadLine();
                                    model = int.Parse(input);
                                } while (model != 1 && model != 2 );

                                Console.Clear();

                                if (model == 1) //start of model
                                {
                                    cc = 61888.10;
                                    src = 0.013 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
                                    {

                                        sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay != 1 && numpay != 2 && numpay != 3);

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");

                                    }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is CHERY A160 1.6L (M) (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }

                               

                                else//(model==3)
                                {
                                    cc = 64888.1;
                                    src = 0.02 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
                                    {

                                        sfee = cc * 0.08;
                                        do
                                        {
                                            //pre-final display
                                            Console.WriteLine("\n       ***********************************************************************");
                                            Console.Write("\n\t\t Select number of years to pay: ");
                                            Console.Write("\n\t\t   [1] 1 year");
                                            Console.Write("\n\t\t   [2] 2 to 3 years");
                                            Console.Write("\n\t\t   [3] 4 to 5 years");
                                            Console.Write("\n\t\t Enter your choice: ");
                                            input = Console.ReadLine();
                                            numpay = int.Parse(input);
                                        } while (numpay != 1 && numpay != 2 && numpay != 3);

                                        Console.Write("\n\t\t Enter the amount of downpayment: ");
                                        input = Console.ReadLine();
                                        downpay = double.Parse(input);

                                        if (numpay == 1)
                                        {
                                            numpayadd = 0.02 * cc;
                                        }
                                        else if (numpay == 2)
                                        {
                                            numpayadd = 0.06 * cc;
                                        }
                                        else if (numpay == 3)
                                        {
                                            numpayadd = cc * 0.08;
                                        }

                                        totcc = cc + tip + lto + sfee + numpayadd;
                                        balance = totcc - downpay;

                                        if (numpay == 1)
                                        {
                                            mdue = balance / 12;
                                        }
                                        else if (numpay == 2)
                                        {
                                            mdue = balance / 48;
                                        }
                                        else if (numpay == 3)
                                        {
                                            mdue = balance / 60;
                                        }
                                        Console.WriteLine("\n       ***********************************************************************");

                                    }

                                    Console.Clear(); // final display
                                    Console.WriteLine("\n       ***********************************************************************");
                                    Console.WriteLine("\n\t\t Dear " + cname + ", your car is CHERY A160R 1.6L (M) (CBU)!");
                                    Console.WriteLine("\n\t\t Address:     \t" + cadd);
                                    Console.WriteLine("\n\t\t Telephone Number:    " + ctn);
                                    Console.WriteLine("\n\t\t Sales Representative Commission: {0:N2}", src);
                                    Console.WriteLine("\t\t Third Party Insurance: \t{0:N2}", tip);
                                    Console.WriteLine("\t\t LTO Fee: \t{0:N2}", lto);
                                    Console.WriteLine("\t\t Service Fee: \t{0:N2}", sfee);
                                    if (cmode == 1)
                                    {
                                        Console.WriteLine("\t\t Type of payment:        CASH");
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t\t Type of payment:        FINANCING");
                                    }

                                    Console.WriteLine("\n\t\t TOTAL CAR COST: \t{0:N2}", totcc);

                                    if (cmode == 2)
                                    {
                                        Console.WriteLine("\n\t\t Transaction will be done in " + bname + ".");
                                        Console.WriteLine("\n\t\t MONTHLY DUE: {0:N2}", mdue);

                                    }
                                    Console.WriteLine("\n       ***********************************************************************");
                                }
                                break;
                            } //end of model module






                        //start of car 5
                        case 5:
                            {
                                Console.Clear();
                                Console.WriteLine("\n       ********************************************");

                                Console.WriteLine("\n\t\t     ILAO CAR MOTORS ");
                                Console.WriteLine("\t\t      \"drive ahead\" ");

                                Console.WriteLine("\n\t   Drive comfortably with the CHEVROLET cars.");
                                Console.WriteLine("\t   [1] CHEVROLET AVEO5 1.5 SOHC (A) (PREMIUM)	81,622.50");
                                Console.WriteLine("\t   [2] CHEVROLET AVEO5 1.5 SOHC (A) (STD)	   77,047.50");
                                Console.WriteLine("\t   [3] CHEVROLET OPTRA5 1.8 DOHC (A)	        97,593.90");


                                Console.WriteLine("\n       ********************************************");

                                do //start of switching operation among models
                                {
                                    Console.Write("\n\t   Select your choice: ");
                                    input = Console.ReadLine();
                                    model = int.Parse(input);
                                } while (model != 1 && model != 2 && model != 3);

                                Console.Clear();

                                if (model == 1) //start of model
                                {
                                    cc = 81622.5;
                                    src = 0.01 * cc;
                                    tip = cc * 0.1;
                                    lto = cc * 0.05;
                                    if (cmode == 1)
                                    {
                                        sfee = cc * 0.05;
                                    }
                                    else //(cmode==2)
              

Recommended Answers

All 3 Replies

You have a series of if/else if statements where those variables are assigned with no else statement at the end. What happens if the system goes through those choices and your value doesn't fit any of the criteria -- the variable goes unassigned. So either make your last else if in the series into an else (which will catch anything that doesn't match) or come up with something to put into the variable in the else statment. So for example:

if (numpay == 1)
{
   numpayadd = 0.02 * cc;
}
else if (numpay == 2)
{
   numpayadd = 0.06 * cc;
}
    [COLOR="Green"]else [/COLOR]
{
   numpayadd = cc * 0.08;
}

or

if (numpay == 1)
{
    numpayadd = 0.02 * cc;
}
else if (numpay == 2)
{
    numpayadd = 0.06 * cc;
}
else if (numpay == 3)
{
    numpayadd = cc * 0.08;
}
[b]else
{
      numpayadd = -999;
} [/b]

The only problem with the second one is you'd have to check for that error in subsequent calculations.

Also, please learn to use code tags:

[code]

//code goes here

[/code]
as they maintain the spacing so code is a lot easier to read. Also, for next time try to pare down your code a bit so that people can find what they are looking for.

commented: Bravo, for reading 2500 lines of code! +6

>use of unassigned local variable..

Run this code,

using System;

public class Test{

     static void Main(){
            int i;

            i++;      // You will get an error here : use of unassigned local variable..

            Console.WriteLine(i);
     }
}

Local variable is initially unassigned.

commented: Bravo, if you made it through about 2500 lines of code! +6

This is a common mistake amongst new coders. You must ensure that all code paths assign a value before you try to access it.
As jonsca pointed out, you are assigning inside if/else statements, but if your code path doesnt fit any of your conditions then it misses all of the assignments. Always ensure you either include an open else to catch occasions where none of your criteria are met or alternatively you can assign a 'default' value when you initialise the variable:

int numpay = 0; //by setting a value from the start you avoid any code paths not assigning a value
...
...
if (numpay == 1)
{
   numpayadd = 0.02 * cc;
}
else if (numpay == 2)
{
   numpayadd = 0.06 * cc;
}
    else 
{
   numpayadd = cc * 0.08;
}

Which approach you use depends on your design and how you use the variable. But the key is to esnure that you dont attempt to retrieve or alter a variable value unless all preceeding code paths result in an assignment

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.