Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IF Else Statement Help

Posted on 2009-03-30
16
Medium Priority
?
262 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:neverenough
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 2
16 Comments
 
LVL 31

Assisted Solution

by:RiteshShah
RiteshShah earned 160 total points
ID: 24025274
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
 
LVL 31

Assisted Solution

by:RiteshShah
RiteshShah earned 160 total points
ID: 24025283
sorry, my above answer was based on the script you provided, I didn't see your attached document.
0
 

Author Comment

by:neverenough
ID: 24025328
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24028967
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
 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24029027
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
 

Author Comment

by:neverenough
ID: 24029454
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
 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24029486
why ??
do you have this?

using System;
using System.Collections.Generic;
using System.Text;
0
 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24029499
try "string" but it's the same
0
 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24033734
is it working now?
acceot my solution if I helped you..
best regards
Cebik
0
 

Accepted Solution

by:
neverenough earned 0 total points
ID: 24034519
Thanks DUDE !   I REALLY APPRICIATE IT !!!!!!!!!!!!!!!!!!!
WISH I COULD GIVE YOU AN ADDITIONAL 500 POINTS !
Soultion accepted !
0
 
LVL 6

Assisted Solution

by:Cebik
Cebik earned 1800 total points
ID: 24034536
Click on button Solution Accepted in my post with code :)
0
 
LVL 6

Expert Comment

by:Cebik
ID: 24034729
It isn't normal way to accept solution even if you want split points...
Read help..
Good luck ;)
0
 

Author Comment

by:neverenough
ID: 24049671
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
 
LVL 6

Expert Comment

by:Cebik
ID: 24050503
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
 

Author Comment

by:neverenough
ID: 24053694
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
 
LVL 6

Expert Comment

by:Cebik
ID: 24053829
I show you example based on your code..
So if will haveing problem than write.. i'll help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question