Write a program which can be used to calculate bonus points to given scores in the range [1..9] according to the following rules:
 If the score is between 1 and 3, the bonus points is the score multiplied by 10
 If the score is between 4 and 6, the bonus points is the score multiplied by 100
 If the score is between 7 and 9, the bonus points is the score multiplied by 1000
 For invalid scores there are no bonus points (0) Your program must make use of 2 parallel arrays – one to store the scores and the other to store the bonus points. You need to make provision for 5 scores (and bonus points) that will need to be stored.
For this program implement the following methods and use these methods in your solution (do not change the method declarations):
static void getScores(int[] scores)
static void calcBonus(int[] scores, int[] bonusPoints)
static void displayAll(int[] scores, int[] bonusPoints)
using System;
public class BonusPoints
{
    const int count = 5;
    static int[] scores = new int[count];
    static int[] bonusPoints = new int[count];
    public static void Main(string[] args)
    {
        getScores(scores);
        calcBonus(scores, bonusPoints);
        displayAll(scores, bonusPoints);
    }
    static void getScores(int[] scores)
    {
        string str = "";
        int Number;
        int i = 0;
        if (scores != null)
        {
            while (i < count)
            {
                Console.Write("Please enter integer:");
                str = Console.ReadLine();
                if (int.TryParse(str, out Number))
                {
                    scores[i] = Number;
                    i++;
                }
            }
        }
    }
    static void calcBonus(int[] scores, int[] bonusPoints)
    {
        if (scores != null && bonusPoints != null)
            for (int i = 0; i < count; i++)
            {
                if (scores[i] >= 1 && scores[i] <= 3)
                    bonusPoints[i] = scores[i] * 10;
                else if (scores[i] >= 4 && scores[i] <= 6)
                    bonusPoints[i] = scores[i] * 100;
                else if (scores[i] >= 7 && scores[i] <= 9)
                    bonusPoints[i] = scores[i] * 1000;
                else
                    bonusPoints[i] = 0;
            }
    }
    static void displayAll(int[] scores, int[] bonusPoints)
    {
        if (scores != null && bonusPoints != null)
        {
            Console.WriteLine("scores:");
            for (int i = 0; i < count; i++)
                Console.Write(scores[i] + " ");
            Console.WriteLine("");
            Console.WriteLine("bonusPoints:");
            for (int i = 0; i < count; i++)
                Console.Write(bonusPoints[i] + " ");
        }
    }
}
Comments