IF Else Statement Help

Hi, i'm working on a practice excercise and i'm totally frustrated and stuck.
I'm trying to write codes for the attached practice excercise and I'm totally lost.
See Attachment :  
You help would be gladly appriciated !!!!


Thanks,
- T
namespace CUSTOMER
{
    class Customer
    {
        static void Main(string[] args)
        {
 
            // Attributes
            String customerName;
            int customerId;
            double accountBalance;
            double processDeposit;
        }
 
 
            // Methods
 
           public string getName()
           {
               return customerName;
           }
         
           public int getId()
           {
               return customerId;
           }
 
           public double getbalance()
           {
               return accountBalance;
           
           }
 
           public double depositAmount()
           {
               return depositAmount;
           }
           
           public double processWithdrawal()
           {
               //return double Withdrawal;
           }
 
          // Constructors 
 
           public Customer()
           {
 
           Console.WriteLine("Please Enter Your Name : ");
           Console.ReadLine();
           Console.WriteLine("Your Name is :{0},customerName");
 
           Console.WriteLine("Please Enter Your Customer ID : ");
           customerId = Convert.ToInt32(Console.ReadLine());
           Console.writeLine("Your Cusotmer ID is :{0},cusotmerId");
 
           Console.WriteLine("Please Enter Your Account Balance");
           accountBalance = Convert.ToDouble(Console.ReadLine());
           Console.WriteLine("Your Account Balance is :{0},accountBalance");
 
           
           }
    }
    class testCustomer
    {
           public static void Main(string[] args)
           {
           double startingBalance,deposit,withDrawal;
           bool validWithdrawal;
           Customer = new Customer();
           console.writLine ("startingBalance is :{0},accountBalance");
 
 
           }

Open in new window

IF-Statement-Exercise-1-.doc
neverenoughAsked:
Who is Participating?
 
neverenoughConnect With a Mentor Author Commented:
Thanks DUDE !   I REALLY APPRICIATE IT !!!!!!!!!!!!!!!!!!!
WISH I COULD GIVE YOU AN ADDITIONAL 500 POINTS !
Soultion accepted !
0
 
RiteshShahConnect With a Mentor Commented:
first. you can't have "static void Main(string[] args)" in two class. Main method is an entry point and you are confusing compiler by giving two Main method.

Second, you have declare following variables in Main Class, how will it be reachable in other method?

 String customerName;
        int customerId;
        double accountBalance;
        double processDeposit;

you should declare it as class level.

there are also few logical mistakes I am seeing, what is your purpose for this script? let me know, I can modify it for you.
0
 
RiteshShahConnect With a Mentor Commented:
sorry, my above answer was based on the script you provided, I didn't see your attached document.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
neverenoughAuthor Commented:
It's a practice excercise i've got for a class. I understand a lot of the stuff, -- technically, I understand what's being asked by the program, but when it's time to put the codes together i always get totally get stuck.
It's an excellerated class, so it's going really quick and i'm falling behind.
That would be great if you can rewrite it for me.

Reagards,
- T
0
 
CebikConnect With a Mentor Commented:
Hello

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Customer testCustom = new Customer();
            Console.WriteLine(testCustom.ToString());
            Console.WriteLine("Customer name = {0}", testCustom.CustomerName);  //proerties
            Console.WriteLine("Customer account {0}", testCustom.AccoutBalance()); //methode must have ()
        }
    }
 
 
    class Customer
    {
        // Attributes
        String customerName;
        int customerId;
        double accountBalance;
        //double processDeposit;
        double depositAmount;
 
        // Properties
        public string CustomerName
        {
            get
            {
                return customerName;
            }
 
            set
            {
                customerName = value;
            }
        }
 
        // Methods
        public int CustomerID()
        {
            return customerId;
        }
 
        public double AccoutBalance()
        {
            return accountBalance;
        }
 
        public double DepositAmount()
        {
            return depositAmount;
        }
 
        // Constructors 
        public Customer()
        {
            Console.WriteLine("Please Enter Your Name : ");
            customerName = Console.ReadLine();
            Console.WriteLine("Your Name is :{0},customerName");
 
            Console.WriteLine("Please Enter Your Customer ID : ");
            customerId = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Your Cusotmer ID is :{0},cusotmerId");
 
            Console.WriteLine("Please Enter Your Account Balance");
            accountBalance = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Your Account Balance is :{0},accountBalance");
 
            depositAmount = 0;
        }
 
        public override string ToString()
        {
            return "Name: " + customerName + ", Account: " + accountBalance.ToString();
        }
    }
 
    
}

Open in new window

0
 
CebikConnect With a Mentor Commented:
ups... few mistakes..
this one is checked..

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Customer testCustom = new Customer();
            
            Console.WriteLine("\n\n"+ testCustom.ToString());
            Console.WriteLine("Customer name: {0}", testCustom.CustomerName);  //proerties
            Console.WriteLine("Customer account: {0}", testCustom.AccoutBalance()); //methode must have ()
 
            Console.ReadLine();
        }
    }
 
 
    class Customer
    {
        // Attributes
        String customerName;
        int customerId;
        double accountBalance;
        //double processDeposit;
        double depositAmount;
 
        // Properties
        public string CustomerName
        {
            get
            {
                return customerName;
            }
 
            set
            {
                customerName = value;
            }
        }
 
        // Methods
        public int CustomerID()
        {
            return customerId;
        }
 
        public double AccoutBalance()
        {
            return accountBalance;
        }
 
        public double DepositAmount()
        {
            return depositAmount;
        }
 
        // Constructors 
        public Customer()
        {
            Console.Write("Please Enter Your Name: ");
            customerName = Console.ReadLine();
            Console.WriteLine("Your Name is: {0}", customerName);
 
            Console.Write("\nPlease Enter Your Customer ID: ");
            customerId = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Your Cusotmer ID is: {0}", customerId);
 
            Console.Write("\nPlease Enter Your Account Balance: ");
            accountBalance = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Your Account Balance is: {0}" ,accountBalance);
 
            depositAmount = 0;
        }
 
        public override string ToString()
        {
            return "Name: " + customerName + ", Account: " + accountBalance.ToString();
        }
    }
 
    
}

Open in new window

0
 
neverenoughAuthor Commented:
Thanks Cebik !!!
I just tested it and got the following error:

Error      1      The type or namespace name 'String' could not be found (are you missing a using directive or an assembly reference?)
0
 
CebikConnect With a Mentor Commented:
why ??
do you have this?

using System;
using System.Collections.Generic;
using System.Text;
0
 
CebikConnect With a Mentor Commented:
try "string" but it's the same
0
 
CebikConnect With a Mentor Commented:
is it working now?
acceot my solution if I helped you..
best regards
Cebik
0
 
CebikConnect With a Mentor Commented:
Click on button Solution Accepted in my post with code :)
0
 
CebikCommented:
It isn't normal way to accept solution even if you want split points...
Read help..
Good luck ;)
0
 
neverenoughAuthor Commented:
I'm kind of new to this.
I wanted to award all of the points to you because you really helped me out, but the instructions said i had to distribute a mimimum of 20 points to each input or something like that.
I'll read help to see how it can be done differently next time.

Thanks !




0
 
CebikCommented:
In this way... I've got smaller number of points..
normaly 500 points * multiplier if A then 500 * 4 = 2000
or 400 * 4  for me
other 100 * 4 for other person..

You welcome..
Bye again
0
 
neverenoughAuthor Commented:
I just reviewed it again and found that you missed out some stuff.
There are some calculation missing for processing the withdrawal etc.
I'll try to figure it out.


* Define three double fields (within the main) called startingBalance, deposit and withdrawal and a bool field called validWithdrawal.
* Instantiate a Customer object.
* Populate the startingBalance field with the accountBalance field from the Customer class.
* Ask the user for, and accept a deposit amount.
* Invoke the processDeposit() method of the Customer class to update the customers balance.
*  Ask the user for and accept a withdrawal amount.
*  Invoke the processWithdrawal() method of the Customer class to update the customers balance and assign the bool value that is returned to the field validWithdrawal.
*  Print out the following activity summary. If processWithdrawal() returns a false value be sure to print out a zero Withdrawal Amount.

0
 
CebikCommented:
I show you example based on your code..
So if will haveing problem than write.. i'll help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.