using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
/******************
* + is addition
* - is subtraction
* * is multipication
* / is division (if both sides are integer then any decimal part is dropped)
* % modulus, returns the remainder from an integer division
* follows same order of operations as algebra
* all multiplications and divisions first left to right
* all substractions and additons left to write
* but what is in parenthesis is first
* embedded parenthesis from inside out
* */
class Program
{
private double total;
private const double TAX = .095;
static void Main(string[] args)
{
Program p = new Program();
//p.GetPrice();
//p.DisplayTotal();
int quotient = p.IntegerDivision(8, 3);
Console.WriteLine("the quotient is {0}", quotient);
int modulus = p.GetTheModulus(8, 3);
Console.WriteLine("the remainder is {0}", modulus);
Console.ReadKey();
}
private void GetPrice()
{
Console.WriteLine("Enter the Price");
double price = double.Parse(Console.ReadLine());
total=GetTotal(price);
}
private double GetTotal(double pr)
{
return pr * (1 + TAX);
}
private void DisplayTotal()
{
Console.WriteLine("Your total is {0:c}",total);
}
private int IntegerDivision(int number1, int number2)
{
return number1 / number2;
}
private int GetTheModulus(int num1, int num2)
{
return num1 % num2;
}
}
}
Thursday, October 4, 2012
Methods and Operators
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment