Question

C# Visual Studios HelloWorld For this assignment, you'll be given two arrays where one represents the...

C# Visual Studios HelloWorld

For this assignment, you'll be given two arrays where one represents the item numbers and the other array represents the price of the item. For instance, index 3 in the items array will have the corresponding price for the item in index 3 of the price array. You'll ask the user which item to lookup, search the array for the item, and print the price when the item is found. When the item was not found, print, Item not found.

Sample

When item exists:

Enter an item number. 98
Price for item 98 is $4.04

When item doesn't exist:

Enter an item number. 33
Item not found
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code:

using System;
class HelloWorld {
static void Main() {
int[] itemnum={34,56,98,45,63};
double[] price={3.02,7.8,4.04,8.2,2.3};
Console.Write("Enter an item number.");
int status=0,itemindex=0;
int item = Convert.ToInt32(Console.ReadLine());
for(int i=0;i<itemnum.Length;i++){
if(itemnum[i]==item){
status=1;
itemindex=i;
break;
}
}
if(status==1){
Console.Write("Price for item "+item+" is $"+price[itemindex]);
}else{
Console.Write("Item not found");
}
  
}
}

#source code along with output:

main.cs 1 using System; 2. class HelloWorld { 3 static void Main() { int[] itemnum={34,56,98,45,63}; double[] price={3.02,7.8

Add a comment
Know the answer?
Add Answer to:
C# Visual Studios HelloWorld For this assignment, you'll be given two arrays where one represents the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Visual Studios HelloWorld For this assignment, you'll work with first creating an array and populating...

    C# Visual Studios HelloWorld For this assignment, you'll work with first creating an array and populating it's values. Then, we'll use the values in the array to calculate the average. Since it's common for an average to result in numbers with decimal points, the array you create should be of type double[]. This program will need to use dynamic input from the user so perform the following steps: Ask the user how many numbers need to be added. Use this...

  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • Exercise Five: (Parallel Array) In this exercise create two string arrays. One array will hold your...

    Exercise Five: (Parallel Array) In this exercise create two string arrays. One array will hold your name, another will hold corresponding password. Example: string name [] = {"name1","name2", "name3"}; string password [] = {"password1", "password2", "password3"}; Here for name1, matching password is password1, name2, matching password is password2 and so on.... Please ignore my creativity, you can pick name and password your way and it doesn't have to have just 3 names and password. It can be less/more. I am...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

  • Needs to be done in visual studio. I keep having problems with making my own function...

    Needs to be done in visual studio. I keep having problems with making my own function to call for the statistics and the random number generator. they are both supposed to be separate functions from the main. Can anyone help? Language is C Overview: This third programming assignment will be the first to require the use of arrays. Like the second program, this program will be modular and make use of functions (including, this time, functions which process arrays). Brief...

  • Please help me! For Problem 1, 2 and 3: You are required to submit three .c...

    Please help me! For Problem 1, 2 and 3: You are required to submit three .c files that contain the instructions that you have written to solve the following problems. Place the C source code to solve the first problem in a file called lab5a.c. Place the C source code to solve the second problem in a file called lab5b.c. And place the C source code to solve the third problem in a file called lab5c.c. Remember to include your...

  • Arrays Arravs Introduction Your ninth programming assignment will consist of two C++programs. Your programs should compile...

    Arrays Arravs Introduction Your ninth programming assignment will consist of two C++programs. Your programs should compile correctly and produce the specified output. Please note that your programs should comply with the commenting and formatting rules we discussed in class. Please see the descriptive ile on eLearning for details. Program 1- Linear Search Algorithm In Computer Science, it is often very important to be able to locate a specific data item inside a list or collection of data. Algorithms that perform...

  • In C Program This program will store the roster and rating information for a soccer team. There w...

    In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...

  • Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm...

    Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm Objective This assignment will consist of writing a program that involves practice with arrays, random number generation, and Strings. You may use c-strings or string objects here, however, string objects is recommended. Exercise Filename: sentences.cpp Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings) called article, noun, verb, and preposition. The arrays...

  • All code will be in Java, and there will be TWO source code. I. Write the...

    All code will be in Java, and there will be TWO source code. I. Write the class  MailOrder to provide the following functions: At this point of the class, since we have not gone through object-oriented programming and method calling in detail yet, the basic requirement in this homework is process-oriented programming with all the code inside method processOrderof this class. Inside method processOrder, we still follow the principles of structured programming.   Set up one one-dimensional array for each field: product...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT