wannapa 5021340003
วันพฤหัสบดีที่ 22 กันยายน พ.ศ. 2554
วันเสาร์ที่ 17 กันยายน พ.ศ. 2554
อนุทินล่าสุด
ช่วงนี้มีแต่การงานเข้ามาตลอด จนไม่มีเวลาพักผ่อนเลย
เพราะว่าช่วงนี้งานเยอะ ไหนจะเรียน ไหนจะทำงาน
จนไม่มีเวลาเหมือนกับเพื่อนๆ บางคน นอนก็น้อยกว่าคนอื่นๆ
เพราะว่าช่วงนี้งานเยอะ ไหนจะเรียน ไหนจะทำงาน
จนไม่มีเวลาเหมือนกับเพื่อนๆ บางคน นอนก็น้อยกว่าคนอื่นๆ
วันพฤหัสบดีที่ 1 กันยายน พ.ศ. 2554
ส่งการบ้านครั้งที่7
ข้อที่ 5.3
using System;
namespace CalculateInterest
{
class Program
{
static void Main(){
Console.Write("Enter principal: ");
string sPrincipal = Console.ReadLine();
decimal mPrincipal = Convert.ToDecimal(sPrincipal);
if (mPrincipal <0)
{
Console.WriteLine("Principal cannot be negative");
mPrincipal = 0;
}
Console.Write("Enter interest: ");
string sInterest = Console.ReadLine();
decimal mInterest = Convert.ToDecimal(sInterest);
if (mInterest < 0)
{
Console.WriteLine("Interest cannot be negative");
mInterest = 0;
}
decimal mInterestPaid;
mInterestPaid = mPrincipal * (mInterest / 100);
decimal mTotal = mPrincipal + mInterestPaid;
Console.WriteLine();
Console.WriteLine("Principal ="+ mPrincipal);
Console.WriteLine("Interest ="+ mInterest + "%");
Console.WriteLine();
Console.WriteLine("Interest paid =" + mInterestPaid);
Console.WriteLine("Total ="+mTotal);
Console.WriteLine("Press Enter to terminnate...");
Console.ReadLine();
}
}
}
ข้อที่5.13
using System;
namespace CalculateInterestTableMoreForgiving{
class Program {
static void Main(string[] args) {
int nMaximumInterest = 50;
decimal mPrincipal;
while(true)
{
Console.Write("Enter principal");
string sPrincipal = Console.ReadLine();
mPrincipal = Convert.ToDecimal(sPrincipal);
if(mPrincipal >= 0)
{
break;}
}
Console.WriteLine("Principal cannot be negatine");
Console.WriteLine("Try again");
Console.WriteLine();
decimal mInterest;
while(true)
{
Console.Write("Enter interest: ");
string sInterest = Console.ReadLine();
mInterest = Convert.ToDecimal(sInterest);
if (mInterest >= 0 && mInterest <= nMaximumInterest)
{
break;
}
Console.WriteLine("Interest cannot be negative " + "or greater than " + nMaximumInterest);
Console.WriteLine("Try again");
Console.WriteLine();
}
Console.Write("Enter number of years: ");
string sDuration = Console.ReadLine();
int nDurstion = Convert.ToInt32(sDuration);
Console.WriteLine();
Console.WriteLine("Principal =" + mPrincipal);
Console.WriteLine("Interest =" + mInterest + "%");
Console.WriteLine("Duration =" + nDurstion + "years");
Console.WriteLine();
int nyear =1;
while (nyear <= nDurstion);
{
decimal mInterestPaid;
mInterestPaid = mPrincipal * (mInterest / 100);
mPrincipal = mPrincipal + mInterestPaid;
mPrincipal = decimal.Round(mPrincipal, 2);
Console.WriteLine(nyear +" - " + mPrincipal);
nyear = nyear +1;
}
Console.WriteLine("Press Enter to terminate...");
Console.Read();
}
}
}
ข้อที่7.7
using System;
namespace studentname
{
class student
{
private int idNumber;
private string lastName;
private double gradePointAversge;
public int getld()
{
return idNumber;
}
public string getName()
{
return lastName;
}
public double getGPA()
{
return gradePointAversge;
}
public void setLd(int id)
{
idNumber = id;
}
public void setName(string name)
{
lastName = name;
}
public void setGPA(double gpa)
{
gradePointAversge = gpa;
}
class Program
{
static void Main()
{
student st = new student();
st.setLd(9353);
st.setName("Teerawat");
st.setGPA(3.98);
Console.WriteLine("Student name {0} has ID # {1} and gpa of{2}",
st.getName(), st.getld(), st.getGPA());
Console.ReadLine();
}
}
}
}
ข้อที่ 8.6
using System;
namespace UserPredefineMethods
{
static class Program
{
static void Main()
{
double[] waterDepht = { 45, 19, 2, 16.8, 190, 0.8, 510, 6, 18 };
string outputMsg = "";
string caption = "System.Array Methods IIIustrated";
double[] w = new double[20];
outputMsg += "waterDepth Array\n\n";
foreach (double wVal in waterDepht)
outputMsg += wVal + "\n";
MessageBox.Show(outputMsg, caption);
Array.Copy(waterDepht, 2, w, 0, 5);
Array.Sort(w);
outputMsg = "Array w Sorted\n\n";
foreach (double wVal in w)
{
if (wVal > 0)
outputMsg += wVal + "\n";
}
MessageBox.Show(outputMsg, caption);
Array.Reverse(w);
outputMsg = "Array w Reversed\n\n";
foreach (double wVal in w)
{
if (wVal > 0)
outputMsg += wVal + "\n";
}
MessageBox.Show(outputMsg, caption);
}
}
}
using System;
namespace CalculateInterest
{
class Program
{
static void Main(){
Console.Write("Enter principal: ");
string sPrincipal = Console.ReadLine();
decimal mPrincipal = Convert.ToDecimal(sPrincipal);
if (mPrincipal <0)
{
Console.WriteLine("Principal cannot be negative");
mPrincipal = 0;
}
Console.Write("Enter interest: ");
string sInterest = Console.ReadLine();
decimal mInterest = Convert.ToDecimal(sInterest);
if (mInterest < 0)
{
Console.WriteLine("Interest cannot be negative");
mInterest = 0;
}
decimal mInterestPaid;
mInterestPaid = mPrincipal * (mInterest / 100);
decimal mTotal = mPrincipal + mInterestPaid;
Console.WriteLine();
Console.WriteLine("Principal ="+ mPrincipal);
Console.WriteLine("Interest ="+ mInterest + "%");
Console.WriteLine();
Console.WriteLine("Interest paid =" + mInterestPaid);
Console.WriteLine("Total ="+mTotal);
Console.WriteLine("Press Enter to terminnate...");
Console.ReadLine();
}
}
}
ข้อที่5.13
using System;
namespace CalculateInterestTableMoreForgiving{
class Program {
static void Main(string[] args) {
int nMaximumInterest = 50;
decimal mPrincipal;
while(true)
{
Console.Write("Enter principal");
string sPrincipal = Console.ReadLine();
mPrincipal = Convert.ToDecimal(sPrincipal);
if(mPrincipal >= 0)
{
break;}
}
Console.WriteLine("Principal cannot be negatine");
Console.WriteLine("Try again");
Console.WriteLine();
decimal mInterest;
while(true)
{
Console.Write("Enter interest: ");
string sInterest = Console.ReadLine();
mInterest = Convert.ToDecimal(sInterest);
if (mInterest >= 0 && mInterest <= nMaximumInterest)
{
break;
}
Console.WriteLine("Interest cannot be negative " + "or greater than " + nMaximumInterest);
Console.WriteLine("Try again");
Console.WriteLine();
}
Console.Write("Enter number of years: ");
string sDuration = Console.ReadLine();
int nDurstion = Convert.ToInt32(sDuration);
Console.WriteLine();
Console.WriteLine("Principal =" + mPrincipal);
Console.WriteLine("Interest =" + mInterest + "%");
Console.WriteLine("Duration =" + nDurstion + "years");
Console.WriteLine();
int nyear =1;
while (nyear <= nDurstion);
{
decimal mInterestPaid;
mInterestPaid = mPrincipal * (mInterest / 100);
mPrincipal = mPrincipal + mInterestPaid;
mPrincipal = decimal.Round(mPrincipal, 2);
Console.WriteLine(nyear +" - " + mPrincipal);
nyear = nyear +1;
}
Console.WriteLine("Press Enter to terminate...");
Console.Read();
}
}
}
ข้อที่7.7
using System;
namespace studentname
{
class student
{
private int idNumber;
private string lastName;
private double gradePointAversge;
public int getld()
{
return idNumber;
}
public string getName()
{
return lastName;
}
public double getGPA()
{
return gradePointAversge;
}
public void setLd(int id)
{
idNumber = id;
}
public void setName(string name)
{
lastName = name;
}
public void setGPA(double gpa)
{
gradePointAversge = gpa;
}
class Program
{
static void Main()
{
student st = new student();
st.setLd(9353);
st.setName("Teerawat");
st.setGPA(3.98);
Console.WriteLine("Student name {0} has ID # {1} and gpa of{2}",
st.getName(), st.getld(), st.getGPA());
Console.ReadLine();
}
}
}
}
ข้อที่ 8.6
using System;
namespace UserPredefineMethods
{
static class Program
{
static void Main()
{
double[] waterDepht = { 45, 19, 2, 16.8, 190, 0.8, 510, 6, 18 };
string outputMsg = "";
string caption = "System.Array Methods IIIustrated";
double[] w = new double[20];
outputMsg += "waterDepth Array\n\n";
foreach (double wVal in waterDepht)
outputMsg += wVal + "\n";
MessageBox.Show(outputMsg, caption);
Array.Copy(waterDepht, 2, w, 0, 5);
Array.Sort(w);
outputMsg = "Array w Sorted\n\n";
foreach (double wVal in w)
{
if (wVal > 0)
outputMsg += wVal + "\n";
}
MessageBox.Show(outputMsg, caption);
Array.Reverse(w);
outputMsg = "Array w Reversed\n\n";
foreach (double wVal in w)
{
if (wVal > 0)
outputMsg += wVal + "\n";
}
MessageBox.Show(outputMsg, caption);
}
}
}
วันศุกร์ที่ 5 สิงหาคม พ.ศ. 2554
โปรแกรม 4.5
using System;
namespace ShortCircuit
{
class Program
{
static void Main(string[] args)
{
int x = 4;
int y = 5;
Console.WriteLine("x = {0}, y = {1}", x, y);
bool result = true || (++x == y);
Console.WriteLine("result = {0}", result);
Console.WriteLine("x = {0}, y = {1}", x, y);
result = true && (++x == y);
Console.WriteLine("result = {0}", result);
Console.WriteLine("x = {0}, y = {1}", x, y);
Console.ReadLine();
}
}
}
namespace ShortCircuit
{
class Program
{
static void Main(string[] args)
{
int x = 4;
int y = 5;
Console.WriteLine("x = {0}, y = {1}", x, y);
bool result = true || (++x == y);
Console.WriteLine("result = {0}", result);
Console.WriteLine("x = {0}, y = {1}", x, y);
result = true && (++x == y);
Console.WriteLine("result = {0}", result);
Console.WriteLine("x = {0}, y = {1}", x, y);
Console.ReadLine();
}
}
}
โปรแกรม 4.2
using System;
namespace DisplaySomeMoney
{
class Program
{
static void Main()
{
double someMoney = 39.45;
Console.Write("The money is ");
Console.WriteLine(someMoney);
double someMoney1 = 39.46;
Console.Write("The money is ");
Console.WriteLine(someMoney1);
double someMoney2 = 39.47;
Console.Write("The money is ");
Console.WriteLine(someMoney2);
double someMoney3 = 39.48;
Console.Write("The money is ");
Console.WriteLine(someMoney3);
double someMoney4 = 39.49;
Console.Write("The money is ");
Console.WriteLine(someMoney4);
double someMoney5 = 39.50;
Console.Write("The money is ");
Console.WriteLine(someMoney5);
Console.ReadLine();
}
}
}
namespace DisplaySomeMoney
{
class Program
{
static void Main()
{
double someMoney = 39.45;
Console.Write("The money is ");
Console.WriteLine(someMoney);
double someMoney1 = 39.46;
Console.Write("The money is ");
Console.WriteLine(someMoney1);
double someMoney2 = 39.47;
Console.Write("The money is ");
Console.WriteLine(someMoney2);
double someMoney3 = 39.48;
Console.Write("The money is ");
Console.WriteLine(someMoney3);
double someMoney4 = 39.49;
Console.Write("The money is ");
Console.WriteLine(someMoney4);
double someMoney5 = 39.50;
Console.Write("The money is ");
Console.WriteLine(someMoney5);
Console.ReadLine();
}
}
}
โปรแกรม 4.4
using System;
namespace Relational {
class Program {
static void Main(string[] args){
int x = 17;
int y = 5;
Console.WriteLine("{0} =={1}={2}", x, y, x == y);
Console.WriteLine("{0} !={1}={2}", x, y, x != y);
Console.WriteLine("{0} < {1}={2}", x, y, x < y);
Console.WriteLine("{0} <={1}={2}", x, y, x <= y);
Console.WriteLine("{0} > {1}={2}", x, y, x > y);
Console.WriteLine("{0} >= {1}={2}", x, y, x >= y);
Console.ReadLine();
}
}
}
โปรแกรม4.1
using System;
namespace integerRange {
class Program {
static void Main() {
Console.WriteLine("min sbte = " + SByte.MinValue);
Console.WriteLine("max sbte = " + SByte.MaxValue);
Console.WriteLine("min byte = " + Byte.MinValue);
Console.WriteLine("max byte = " + Byte.MaxValue);
Console.WriteLine("min short = " + Int16.MinValue);
Console.WriteLine("max short = " + Int16.MaxValue);
Console.WriteLine("min ushort = " + UInt16.MinValue);
Console.WriteLine("max ushort = " + UInt16.MaxValue);
Console.WriteLine("min int = " + Int32.MinValue);
Console.WriteLine("max int = " + Int32.MaxValue);
Console.WriteLine("min uint = " + UInt32.MinValue);
Console.WriteLine("max uint = " + UInt32.MaxValue);
Console.WriteLine("min long = " + Int64.MinValue);
Console.WriteLine("maxlong = " + Int64.MaxValue);
Console.WriteLine("min ulong = " + UInt64.MinValue);
Console.WriteLine("max ulong = " + UInt64.MaxValue);
Console.ReadLine();
}
}
}
สมัครสมาชิก:
บทความ (Atom)