Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for C# Please complete the incomplete code: using System; namespace Quiz_2_Kevin_Kevin { class Program { public static readonly string[] vegetables = {amaranth,arugula,beet,bok choy,

This is for C#

image text in transcribed

Please complete the incomplete code:

using System;

namespace Quiz_2_Kevin_Kevin { class Program { public static readonly string[] vegetables = {"amaranth","arugula","beet","bok choy", "borage","broccoli","brussell sprouts", "cabbage","catsear","celery","celtuce","chaya","chickweed","chicory","chinese mallow", "chrysanthemum leaves", "collard greens","common purslane","corn salad","cress","dandelion", "dill","endive","fat hen","fiddlehead","fluted pumpkin","garden rocket","golden samphire", "good King Henry","grape leaves","greater plantain","kai-lan","kale","Komatsuna","kuka", "lagos bologi","lamb's lettuce","lamb's quarters","land cress","lettuce","lizard's tail", "malabar spinach","melokhia","miner's lettuce","mizuna greens","mustard","Napa cabbage", "New Zealand spinach","orache","pak choy","paracress","pea sprouts","poke","radicchio", "rapini","samphire","sculpit","stridolo","sea beet","sea kale","Sierra Leone bologi", "soko","sorrel","sour cabbage","spinach","summer purslane","swiss chard","tatsoi", "turnip greens","watercress","water spinach","wheatgrass","yarrow","yao choy","shepher's purse"};

public static readonly string[] botanicalFruits = { "avocado","bell pepper","bitter melon","bitter gourd","chayote", "cucumber","ivy gourd","eggplant","aubergine","brinjal","luffa","olive fruit","pumpkin","pineapple", "squash","sweet pepper","tinda","tomatillo","tomato","vanilla","West Indian gherkin","winter melon", "zucchini","courgette","marrow"};

public static readonly string[] flowersAndFlowerBuds = { "artichoke","broccoli","broccolini flowers","caper","cauliflower", "daylily","courgette flowers","squash blossoms"};

public static readonly string[] poddedVegetables = { "American groundnut","azuki bean","black-eyed pea","chickpea", "common bean","drumstick","dolichos bean","fava bean","garbanzo","green bean","guar", "horse gram","India pea","lentil","lima bean","moth bean","mung bean","okra","pea", "peanut","pigeon pea","ricebean","runner bean","snap pea","snow pea","soybean","tarwi", "tepary bean","urad bean","velvet bean","winged bean","yardlong bean"};

public static readonly string[] bulbAndStemVegetables = { "asparagus","cardoon","celeriac","celery","chives", "elephant garlic","Florence fennel","garlic","garlic chives","kohlrabi","kurrat", "lemongrass","leek","lotus root","nopal","onion","pearl onion","potato onion", "Prussian asparagus", "spring onion","scallion","shallot","tree onion","Welsh onion", "wild leek","gau soon"};

public static readonly string[] rootAndTuberousVegetables = { "ahipa","arracacha","bamboo shoot","beetroot","burdock", "broadleaf arrowhead","camas","canna","carrot","cassava","Chinese artichoke", "daikon","Earthnut pea","elephant foot yam","ensete","galangal","ginger", "Hamburg parsley","horseradish","Jerusalem artichoke","jicama","mashua","parsnip", "pignut","potato","prairie turnip","radish","rutabaga","salsify","scorzonera", "skirret","swede","sweet potato","taro","ti","tigernut","turmeric","turnip", "ulluco","wasabi","water caltrop","water chestnut","yacon","yam"};

public static readonly string[] seaVegetables = { "aonori","arame","carola","dabberlocks","dulse","hijiki","kombu", "laver","gim","mozuku","nori","ogonori","sea grape","sea lettuce","wakame"};

/* * there are literally hundreds of culinary fruits * ...I just included a sampling here. */ public static readonly string[] culinaryFruits = { "Acai","African moringa","Amazon tree-grape","American black elderberry", "American grape","apple","banana","blueberry","cantaloupe","Chinese jujube","coconut", "coffee","Cornelian cherry","Costa Rican guava","date","dragonfruit","Indian gooseberry", "fig","gooseberry","grapefruit","Chilean guava","honeydew","Indian prune","jabuticaba", "Korean melon","kumquat","lime","mango","nectarine","orange","pawpaw","peach","pear", "quince","raspberry","rhubarb","Spanish lime","strawberry","tangerine","ugni","vanilla", "watermelon","youngberry","zwetsche"};

public static readonly int[] integerArray = { 5, 76, 888, 4356, -7, -458, 44 };

public static readonly float[] floatArray = { 3.14159f, 42.4f, 3.3f, 98.6f, -987.0f, -200.0001f, 5_678.3f };

static void Main(string[] args) { Console.WriteLine("Brett Robblee's Quiz 2"); string findThis; int index = -1;

findThis = "mustard"; index = findElement(findThis, vegetables); if (index > -1) Console.WriteLine("Found vegetable: {0}", vegetables[index]); else Console.WriteLine("{0} not found.", findThis);

/* * Requirement #6 -- follow the instructions in the comments on lines 92-98 * Hint: this is easy because I already wrote the code. You just have to copy and adapt. */ // replicate lines 81-86 here and search and find an element in the flowersAndFlowerBud array // search and find an element in the poddedVegetables array // search and find an element in the bulbsAndStemVegetables array // search and find an element in the rootAndTuberousVegetables array // search and find an element in the seaVegetables array // search and find an element in the culinaryFruits array // search BUT DO NOT FIND an element in the culinaryFruits array to prove that your "else" code works.

index = findElement(-458, integerArray); if (index > -1) Console.WriteLine("Found integer: {0}", integerArray[index]);

index = findElement(3.14159f,floatArray); if (index > -1) Console.WriteLine("Found float: {0}", floatArray[index]);

Console.WriteLine("The sum of the elements in integerArray is {0}", sumElements(integerArray));

Console.WriteLine("The sum of the elements in floatArray is {0}", sumElements(floatArray)); }

/* Requirement #1 must implement a method/function called findElement() that accepts 2 arguments ([1] a string to search for and [2] an array to search) and, if the string is found in the array, returns the index where it is found (0...array.Length-1) or if string is not found, returns -1. */ static int findElement(string element, string[] elementArray ) { // your code here

return -1; }

/* Requirement #2 2. must implement a method/function called findElement() that accepts 2 arguments ([1] an integer to search for and [2] an array to search) and, if the integer is found in the array, returns the index where it is found (0...array.Length-1) or if integer is not found, returns -1. */ static int findElement(int element, int[] elementArray) { // your code here

return -1; }

/* Requirement #3 3. must implement a method/function called findElement() that accepts 2 arguments ([1] a float to search for and [2] an array to search) and, if the float is found in the array, returns the index where it is found (0...array.Length-1) or if float is not found, returns -1. */ static int findElement(float element, float[] elementArray) { //your code here

return -1; }

/* Requirement #4 * must implement a method/function called sumElements() that accepts 1 argument (an integer array) and returns the sum. */ static int sumElements(int[] elementArray) { // your code here

return sum; }

/* Requirement #5 * must implement a method/function called sumElements() that accepts 1 argument (a float array) and returns the sum. */ static float sumElements(float[] elementArray) { //your code here

return sum; }

} }

I wrote a program that is incomplete. Your task is to complete the program. Read the requirement carefuily and work methodically-don't jump around-focus on one thing at a time. It may look scary but It shouldn't be too hard because I built the entire structure for you Refer to the textbook chapters, videos, and ppt slides for help. This quiz covers Chapters 5,6,7 and 8 in the textbook-Looping. Using Arrays, Using Methods, and Advanced Method Concepts, respectively. Your task for this quiz is to write a program The requirements for your program are as follows: Your program 0 must download quiz2 cs and change namespace to Quiz_2 your_name 1. must implement a method/function called findElement that accepts 2 arguments ([1] a string to search for and [2] an array to search) and, if the string is found in the array, returns the index where it is found (0..array Length-1) or if string is not found, returns -1 2. must implement a method/function called findElement) that accepts 2 arguments ([1] an integer to search for and [2] an array to search) and, if the integer is found in the array, returns the index where it is found (0...array. Length-1) or if integer is not found, returns-1. 3. must implement a method/function called findElement) that accepts 2 arguments ([1] a float to search for and [21 an array to search) and, if the float is found in the array, returns the index where it is found (0...array Length-1) or if float is not found, returns -1 4. must implement a method/function called sumElements)that accepts 1 argument (an integer aray) and returns the sum. 5. must implement a method/Tunction called sumElements) that accepts 1 argument (a float array) and returns the sum 6. must add method calls in method Main) to invoke findElement) on the following arrays . flowersAndFlowerBuds . poddedVegetables bulbsAndStemVegetables rootAndTuberousVegetables seaVegetables culinaryFrus Hint: this is simple. Just copy similar code (lines 85-88) and update appropriately. Please add after line 88 and follow the list order to speed my turn-around time on grading

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions