Answer to Question #15912 in C# for leena

Question #15912
Define a class vector to hold 3 integer values. Include operator methods such that we shall be able to perform these operations on the vector object V1, V2 & V3.
1)V3=V1+V2;
2)V3=5*V1;
3)V3=V2*5;
4)int m= V1*V2
1
Expert's answer
2012-10-05T08:11:40-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
public class Vector
{
& int a, b, c;
& public Vector plus(Vector k)
& {
Vector D = new Vector();
D.a = a + k.a;
D.b = b + k.b;
D.c = c + k.c;
return D;
& }
& public Vector plusMultiply5()
& {
Vector D = new Vector();
D.a = a * 5;
D.b = b * 5;
D.c = c * 5;
return D;
& }
& public int muliply(Vector D)
& {
return D.a * a + D.b * b + D.c * c;
& }
}
class Program
{
& static void Main(string[] args)
& {

& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS