Question

In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61,...

In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, and 66. Use a loop to call a method from main() that adds 15 points to all student grades that are a C or above. A C is defined as a score of 70 or above. Make this happen by passing the subscript value and not the entire array. The addition of the 15 points should happen in the method and be passed back to main. Use a loop to show final values within the array. The final array values should show the new adjusted grades

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System.IO;
using System;

class Program
{
    //function to add 15 to grades above C
    public static int addValue(int value){
        if(value>=70)
            value=value+15;
        return value;
    }
    //main function
    static void Main()
    {
        //initial array
        int[] a=new int[]{90,61,74,42,83,51,71,83,98,87,94,68,44,66};
      
        //printing values in initial array
        Console.Write("Initial Grades: ");
        for(int i=0;i<a.Length;i++){
            Console.Write(a[i]+" ");
        }
        Console.WriteLine();
      
        //adjusting the grades
        for(int i=0;i<a.Length;i++){
            a[i]=addValue(a[i]);
        }
      
        //printing the adjusted values
        Console.Write("Adjusted Grades: ");
        for(int i=0;i<a.Length;i++){
            Console.Write(a[i]+" ");
        }
        Console.WriteLine();
      
    }
}

//############################################################################

OUTPUT
###########

Add a comment
Know the answer?
Add Answer to:
In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61,...
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
  • In Visual Studio 2017 Populate a two-dimensional array with the following prices in this table order:...

    In Visual Studio 2017 Populate a two-dimensional array with the following prices in this table order: 32.34 22.33 68.30 36.99 43.94 63.67 55.89 67.44 13.77 87.13 54.99 87.78 18.42 21.60 45.98 66.03 41.38 74.48 24.21 67.10 61.23 Write a method/function which uses loops and is called from main() that increases the prices by 6.5% and stores the new price in the same array. All changes to the array must be made inside the method/function. Please display the original array in...

  • C++ ONLY THANKS! USE VISUAL STUDIO COMPILER ONLY! Part 1: Exercise 1: Problem description Write a...

    C++ ONLY THANKS! USE VISUAL STUDIO COMPILER ONLY! Part 1: Exercise 1: Problem description Write a three function program (your main function and two other functions). The main function of the program should create an array that can store 10 integers. The main function will then pass the array to a second function that gets the integers from the user and stores them in the array. Then your main will call a third function that displays the elements in the...

  • Lab Objectives Be able to write methods Be able to call methods Be able to declare...

    Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...

  • Hi!, having trouble with this one, In this class we use visual studio, C++ language --------------------------------------------------------------...

    Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...

  • C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand h...

    C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand how to traverse a two dimensional array Code and run a program that processes a two dimensional array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the main diagonal, and sum of the reverse diagonal are all the same value. You are to code a program to determine...

  • Please write below code in C++ using Visual Studio. Write program that uses a class template...

    Please write below code in C++ using Visual Studio. Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...

  • HOW TO FiX EXCEPTIONS??? In order to populate the array, you will need to split() each...

    HOW TO FiX EXCEPTIONS??? In order to populate the array, you will need to split() each String on the (,) character so you can access each individual value of data. Based on the first value (e.g., #) your method will know whether to create a new Manager, HourlyWorker, or CommissionWorker object. Once created, populate the object with the remaining values then store it in the array. Finally, iterate through the array of employees using the enhanced for loop syntax, and...

  • Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually...

    Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually kind of confusing to me. I keep getting lost in all of the words even though these are supposed to instruct me as to how to do this. Can I please get some help as to where to start? Word guessing game: Overview: Create a game in which the user has a set number of tries to correctly guess a word. I highly recommend...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

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