Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP - no one has been able to get this correct or follow the directions

ID: 3860943 • Letter: P

Question

PLEASE HELP - no one has been able to get this correct or follow the directions so far!

Be sure to read the assignment requirements carefully; maybe more than once. Be sure you understand the requirements.

NOTE FROM INSRTUCTOR: This assignment might look similar to a previous assignment but for this assignment you have an array of 5 strings to hold the string part name and price (both are part of each string entry). You need to parse out the name for each array element and assign it to a separate string array of part names. You then need to parse out the part of each string that comprises the price, convert it to double and assign it to the corresponding index in a parsed price array. This is done by passing the arrays to the parseIt method and performing the parsing/conversion task. In Main, use a for loop to display the parsed name and the parsed price. You are taking an array of strings that hold both the name and price in a single string, you parse out the two parts and you assign them to their appropriate array to create the two arrays you started with in last week's assignment.

Develop a C# console application that implements three arrays; a string array initialized with exactly the following five data items { "Widget 15.50", "Thingy 50.99", "Ratchet25.00", "Clanger115.49", "Fracker75.25" }, a string array to hold the five part names to be parsed from the previously detailed string array, an array of five double value prices to be parsed from the previously mentioned array.

Create a void method that will accept as arguments the two arrays of strings and the array of doubles when called from Main. In the method you will access the five members of the first string array mentioned above and you will parse out the name portion of each string element (first 7 bytes), assigning the string value to the corresponding element in the array of names. In the method you will also parse out the numeric portion of each string and assign it to the corresponding element of the price array. The parsing should be done using the string method SubString.

In Main, after calling the parsing method you will display the elements of both the array of names and the array of prices side-by-side (do not display the array from which you parsed the data items).

The output should look something like this:

Widget $15.50
Thingy $50.99
Ratchet $25.00
Clanger $115.49
Fracker $75.25
Press any key to continue . . .

Name the .cs file Assignment_8_yourlastname and submit it to the link below.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assignment_8
{
    class Assignment_8
    {
        static void Main(string[] args)
        {
            string[] item_name = new string[5] { "Widget", "Thingy", "Ratchet", "Clanger", "Fracker" };
            double[] item_price = new double[5] { 15.50, 50.99, 25.00, 115.49, 75.25 };

            for (int x = 0; x <= 4; x++)
            {
                Console.WriteLine("The price for item {0} is {1:c}", item_name[x], item_price[x]);
            }

            Console.Write(" Enter the price cutoff point (eg $15.00) $");
            double cutOff = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter the percentage price change (eg 0.25) ");
            double pricePerc = Convert.ToDouble(Console.ReadLine());
            Console.Write(" )");

            for(int a=0; a<=4; a++)
            {
                item_price[a] = changePrices(item_price[a], cutOff, pricePerc);
                printit(item_name[a], item_price[a]);
            }

            Console.WriteLine(" Press any key to continue...");
            Console.ReadKey();        
        }

        static double changePrices(double price, double priceCutOff, double costPercentage)
        {
            if (price < priceCutOff)
            {
                price = ((price * costPercentage) + price);
                return price;
            }
            else
            {
                return price;
            }
        }

        static bool printit(string item, double newprice)
        {
            Console.WriteLine("The price for item {0} is {1:c}", item, newprice);
            return true;
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote