hello all.

i have endured hell for the last 2 days trying to get the scores from this program being a user quiz to make it add up the scores and keep a rolling total to be presented as a total score at then end of the quiz, but i'm struggling so much....could anyone help out?

here is my code so far:

using System;
using System.Collections.Generic;
using System.Text;


//namespace declaration
namespace Quiz
	
	
{
//program start class	
class Program
{
	
static void Main(string[] args)
{
SquareA sA = new SquareA("square");
sA.Print();
RectangleA rA = new RectangleA("rectangle");
rA.Printr();
CircleA cA = new CircleA("circle");
cA.Printc();
SquareP sP = new SquareP("square");
sP.Print();
RectangleP rP = new RectangleP("rectangle");
rP.Printr();
CircleP cP = new CircleP("rectangle");
cP.Printr();
AND and = new AND("AND gate");
and.Print();
OR or = new OR("OR gate");
or.Printor();
NOT not = new NOT("not gate");
not.Printnot();
}
}

class Area
{
protected String name;
protected String namera;
protected String nameca;
protected int squarelength;
protected double squareArea;
protected int rectangleLength;
protected int rectangleWidth;
protected double rectangleArea;
protected int circleRadius;
protected double circleArea;
int score;

		
public void Print()
{	
Console.WriteLine("Welcome to the quiz! - There will be three questions to answer");
Console.WriteLine("\nThese will be based on Area, Perimeter and Logic Gates");
int score = 0;
Console.WriteLine("\nQuestion 1");
Console.WriteLine("\nIf the length of the square is {0} what is the area going to be?", squarelength);
double squareAreaIn = Convert.ToInt32(Console.ReadLine());
if (squareAreaIn==squareArea)
{
score++;
Console.WriteLine("\nYour answer is correct, your score is now {0}",score);
}
else 
Console.WriteLine("\nYour answer is incorrect, your score is now {1}",score);
}
public void Printr()
{
int score = 1;
Console.WriteLine("\nQuestion 2");
Console.WriteLine("\nIf the length of the rectangle is {0}, and the width is {1}cm what is the area going to be?",rectangleLength, rectangleWidth);
double rectangleAreaIn = Convert.ToInt32(Console.ReadLine());
if (rectangleAreaIn == rectangleArea)
{
score++;
Console.WriteLine("\nYour answer is correct, your score is now {0}",score);
}
else 
Console.WriteLine("\nYour answer is incorrect, your score is still {1}", score);
}			
public void Printc()
{
int score = 2;
Console.WriteLine("\nIf the radius of a circle is {0} what is the area going to be?",circleRadius);
double circleIn = Convert.ToDouble(Console.ReadLine());
if (circleIn == circleArea)
{
Console.WriteLine("Your answer is correct, your score is now {0}",score);
}
else 
Console.WriteLine("\nYour answer is incorrect, your score is still {1}", score);
}	
}

class SquareA : Area
{
public SquareA(string n)
{
squarelength = 10;
squareArea = squarelength*squarelength;
name = n;
}
}

class RectangleA : Area
{
public RectangleA(string n)
{
rectangleLength = 10;
rectangleWidth = 10;
rectangleArea = rectangleLength*rectangleWidth;
namera = n;
}
}

class CircleA : Area
{
public CircleA(string n)
{
circleRadius = 5;
circleArea = (circleRadius*circleRadius)*3.14 ;
nameca = n;
}
}

class Perimeter
{
protected String name;
protected String namerp;
protected String namecp;
protected int squareLength;
protected int squarePerimeter;
protected int rectangleLength;
protected int rectangleWidth;
protected int rectanglePerimeter;
protected double circleDiameter;
protected double circlePerimeter;



public void Print()
{	
Console.WriteLine("\nIf the length of a square is {0} what is the perimeter going to be?", squareLength);
int squarePerimeterIn = Convert.ToInt32(Console.ReadLine());if (squarePerimeterIn==squarePerimeter)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}
public void Printr()
{
Console.WriteLine("If the length = {0} of a a rectangle and the lengthnis {1} what is the Perimeter?",rectangleLength, rectangleWidth);
int rectanglePerimeterIn = Convert.ToInt32(Console.ReadLine());
if (rectanglePerimeterIn == rectanglePerimeter)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}	
public void Printc()
				{
Console.WriteLine("if the diameter of the circle is {0}",circleDiameter);
int circlePerimeterIn = Convert.ToInt32(Console.ReadLine());
if (circlePerimeterIn == circlePerimeter)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}
}

class SquareP : Perimeter
{
public SquareP(string n)
{
squareLength = 10;
squarePerimeter = squareLength*4;
name = n;
 }

 }	
	
class RectangleP : Perimeter
{
public RectangleP(string n)
{
rectangleLength = 10;
rectangleWidth = 10;
rectanglePerimeter = rectangleLength+rectangleLength+rectangleWidth+rectangleWidth;
namerp = n;
}
}
	
class CircleP : Perimeter
{
public CircleP(string n)
{
circleDiameter = 10;
circlePerimeter = circleDiameter*3.14;
namecp = n;
}
		
}
class Logic
{
protected String name;
protected String nameor;
protected String namenot;
protected int ANDinput1;
protected int ANDinput2;
protected int ANDanswer;
protected int ORinput1;
protected int ORinput2;
protected int ORanswer;
protected int NOTinput1;
protected int NOTanswer;

public void Print()
{	
Console.WriteLine("if the input for a AND gate was {0} and {1}", ANDinput1,ANDinput2);
int ANDIn = Convert.ToInt32(Console.ReadLine());
if (ANDIn==ANDanswer)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}
public void Printor()
{
Console.WriteLine("if the input for a or gate was {0} and {1}",ORinput1, ORinput2);
int ORIn = Convert.ToInt32(Console.ReadLine());
if (ORIn == ORanswer)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}	
		
public void Printnot()
{
Console.WriteLine("if the input for a not gate was {0} whats the ouput",NOTinput1);
int NOTIn = Convert.ToInt32(Console.ReadLine());
if (NOTIn == NOTanswer)
{
Console.WriteLine("Your answer is Correct");
}
else 
Console.WriteLine("Wrong");
}	
}

class AND : Logic
{
public AND(string n)
{
ANDinput1 = 1;
ANDinput2 = 0;
ANDanswer = 0;
name = n;
}
}	
	
class OR : Logic
{
public OR(string n)
{
ORinput1 = 1;
ORinput2 = 1;
ORanswer = 1;
nameor = n;
}
}

class NOT : Logic
{
public NOT(string n)
{
NOTinput1 = 1;
NOTanswer = 0;
namenot = n;
}
}	
}

Please put your code inside of [ c o d e = c s h a r p ] tags (without the spaces). It will make it more readable. Also, that is a lot of code to look through without knowing the exact problem. You will probably get no help because of this. Try explaining in more thorough detail where you are having issues, and then post less code that pertains to the problem area.

cant delete this post
can somebody tell me how please?

Posts can be edited within 30 minutes of submission. After that, only a moderator of administrator can edit the post. Posts will only be deleted if they are in violation of the site rules.

great, thats not very good is it then. mod please delete if you read this!!!!!

As I already said, it will not be deleted unless the post is in violation of the rules and I do not see any reason to do so in this case.

Why are you setting the score variable in each of the print options, you are correct to do score++ to increment the score but if you keep resetting score in print, printc, printr it won't be a true total.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.