Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c# visual studios In this problem, you will be using a loop to combine 2 string arrays together. First, start by creating a string array

c# visual studios

In this problem, you will be using a loop to combine 2 string arrays together.

First, start by creating a string array called randomThings. Fill this string array with at least 4 strings that are items around the home. This will be hard-coded, which means that you type them into your code and these values do not come from the user.

Create a second string array called colors. Fill this string array with the same number of elements as the first array. These will be strings that will be the main color of the items in the first array. Make sure the matching elements are in the same index in each array. This will also be hard-coded and not from the user.

Then create a loop that will cycle through both arrays. Inside of the loop, you will combine the matching array elements into an output for the user.

It should be of the form of The main color of the object is color.

This output must come from the loop, it should not be hardcode for each object one at a time.

  • User Inputs:
    • No user inputs for this problem.

  • Result To Print Out:
    • The main color of the object is color.
      • Where object is the element from the randomThings.
      • Where color is the element from the colors.

  • Data Sets To Test:
    • Test 1:
      • randomThings grapes, apples, limes, lemons
      • colors purple, red, green, yellow
      • Final Outputs
        • The main color of the grapes is purple.
        • The main color of the apples is red.
        • The main color of the limes is green.
        • The main color of the lemons is yellow.

    • Test 2:
      • randomThings ball, carrot, towel, laptop, stove
      • colors red, orange, white, silver, black
      • Final Outputs
        • The main color of the ball is red.
        • The main color of the carrot is orange.
        • The main color of the towel is white.
        • The main color of the laptop is silver.
        • The main color of the stove is black.

  • For each problem you will need the following:
    • Label the section of code appropriately
    • Prompt the user for each variable that is in the User Input Section of that problem.
    • Validate each user prompt with a while loop to ensure that the user is typing in a valid response. Remember we check text string different than numbers!
    • Convert each users response to the correct data type, if needed.
    • The result should be calculated using variables, not literal values when possible.
    • Create code that will make decisions based on the value of the users responses.
    • Print the result of the decision-making to the console using the format given in the Results section of that problem.
    • Make sure you test your code with the Test Values given.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions