I'm having the most difficult time trying to word pseudo code for this program i have. When I start to write the p.code it's like i don't know how to word it. I understand its just like translating the language to terms where non programers can understand it. but i've never really had to write p.code until now so that i can understand how to write it in the future if im recommended to. The program is just something i threw together to see if i could write p.code...If someone could like walk me through this it will be greatly appreciated. I've read books but it just confuses me more. The program just basically add or subtract numbers as if you were adding your monthly bills together to see exactly what you have to spend or have spent on monthly bills.....
Here's the code:
using System;
namespace Addingnumbers
{
public delegate int mathsOp(int value1, int value2, int value3, int value4);
class MathClass
{
public int add(int value1, int value2, int value3, int value4)
{
return value1 + value2 + value3 + value4;
}
public int sub(int value1, int value2, int value3, int value4)
{
return value1 - value2 - value3 - value4;
}
}
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("This is a program that will add your monthly bills with the option to subtract.....");
Console.WriteLine("Whole numbers Only");
MathClass mathFunc = new MathClass();
mathsOp theMathOp;
Console.Write("Please enter bill total 1 : ");
int inputValue1 = Convert.ToInt16(Console.ReadLine());
Console.Write("Please enter bill total 2 : ");
int inputValue2 = Convert.ToInt16(Console.ReadLine());
Console.Write("Please enter bill total 3 : ");
int inputValue3 = Convert.ToInt16(Console.ReadLine());
Console.Write("Please enter bill total 4 : ");
int inputValue4 = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Please enter maths function :");
Console.WriteLine("1 : add");
Console.WriteLine("2 : sub");
int mathsInputFun = Convert.ToInt16(Console.ReadLine());
switch (mathsInputFun)
{
case 1:
theMathOp = new mathsOp(mathFunc.add);
break;
case 2:
theMathOp = new mathsOp(mathFunc.sub);
break;
default:
Console.WriteLine("Settings to add");
theMathOp = new mathsOp(mathFunc.add);
break;
}
Console.WriteLine(" Bill 1 = " + inputValue1 + (mathsInputFun == 1 ? " + " : " - ")
+ " Bill 2 = " + inputValue2 + " Bill 3 = " + inputValue3 + " Bill 4 = " + inputValue4 );
Console.WriteLine(theMathOp(inputValue1, inputValue2, inputValue3, inputValue4));
}
}
}