1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tatiyna
3 years ago
5

Number Array Class

Computers and Technology
1 answer:
UNO [17]3 years ago
4 0

Answer:

Here is the Array class named Number:

#include <iostream>

#include <iomanip>

using namespace std;

class Number {

private:                            

   int size;                      

   float *ptr;                

   float num;                

   

public:                                          

   Number(){

       cout<<"Enter size of array: ";

        cin>>size;                            

   ptr = new float[size];  

   cout<<"Enter elements"<<endl;

   for(int i=0;i<size;i++)     {

       cin>>ptr[i];     }     }

   

   void getNumbers(){

        cout << "{ ";                    

   for (int i = 0; i < size; i++)           {

       cout <<ptr[i] <<setprecision(2)<< " ";             }

   cout << "}";            }

   

   Number(int s){

       ptr = new float[s];          

       size = s;      

   for (int i = 0; i < size; i++)     {

       cout << "Enter elements : ";    

       cin >> num;                          

       ptr[i] = num;         }  }

   

   ~Number(){

        delete [] ptr;    }

   void storeNumber(int input, float num){

        while (input < 0 || input > size-1)  {

       cout << "array size exceeded! Enter an element again " << endl;    

       cin >> input;    

       if (input >= 0 && input < size)  {

           ptr[input] = num;  

           break;       }   }

     if (input >= 0 && input < size)  {

       ptr[input] = num;   }  }

   

   void retrieveNumber(int position){

        while (position < 0 || position > size-1)  {

       cout << "array size exceeded! Enter an element again " << endl;    

       cin >> position;      

        if (position >= 0 && position < size)  {

           cout << "The number at "<<position<<"is: " << ptr[position];  

           break;           }     }      

   if (position >= 0 && position < size)     {

      cout << "The number at "<<position<<" is: " << ptr[position];     }   }    

 

   float HighestNumber(){

       float highest = ptr[0];      

   for (int i = 1; i < size; i++)     {

       if (ptr[i] > highest)         {

           highest = ptr[i];              }     }      

   return highest;      }

   

   float LowestNumber(){

       float lowest = ptr[0];      

   for (int i = 1; i < size; i++)     {

       if (ptr[i] < lowest)         {

           lowest = ptr[i];              }     }      

   return lowest;      }

   

   float AverageNumber(){

       float avg = 0.0;        

   for (int i = 0; i < size; i++)     {

       avg += ptr[i];         }      

   return avg/size;     }    

};

int main() {

   Number array;    

   array.getNumbers();    

   cout << endl;    

   int pos;        

   float no;    

   cout << "Choose an element to replace: ";  

   cin >> pos;    

   cout << "What number do you want to replace element with?" << endl;  

   cin >> no;    

   array.storeNumber(pos, no);

   array.getNumbers();  

   cout << endl;    

   int pos1;  

   cout << "Enter an element to retrieve the number: ";  

   cin >> pos1;    

   cout << endl;  

   array.retrieveNumber(pos1);  

   cout << endl;    

   cout << endl;    

   cout << "The highest number is: " << array.HighestNumber() << endl;    

   cout << "The lowest number is : " << array.LowestNumber() << endl;      

   cout << "Average of all numbers is : " << array.AverageNumber() << endl;    

    cout << endl;    

   return 0;        }

Explanation:

The program is well explained in the comments mentioned with each line of code in the attached document.

The screenshot of the program along with its output is attached.

You might be interested in
What are the cause of eye strain during computer usage?
Natasha2012 [34]
It happens because your eyes follow the same path over and over. And it can get worse the longer you continue the movement. When you work at a computer, your eyes have to focus and refocus all the time. They move back and forth as you read. You may have to look down at papers and then back up to type. Your eyes react to changing images on the screen to create so your brain can process what you’re seeing. All these jobs require a lot of effort from your eye muscles. And to make things worse, unlike a book or piece of paper, the screen adds contrast, flicker, and glare.

You’re more likely to have problems if you already have eye trouble, if you need glasses but don't have them, or if you wear the wrong prescription for computer use.

Computer work gets harder as you age and the lenses in your eyes becomes less flexible. Somewhere around age 40, your ability to focus on near and far objects will start to go away. Your eye doctor will call this condition presbyopia.

5 0
3 years ago
Word offers a multitude of picture formatting options that allow you to flip, rotate, and make many other adjustments to inserte
SIZIF [17.4K]

Answer:

True

Explanation:

In Microsoft Word, there are several formatting options available to format the inserted picture. Whenever we insert a picture, the picture formatting options will appear at the top of the program. One of the option, Rotate, enable user to rotate the picture 90 degree to the left or right and flip it vertically or horizontally. Besides, Word formatting options also include Crop feature, Color Corrections, Transparency Adjustment etc.

8 0
3 years ago
If your TV was showing a flat black or blue screen, or had "snow", what steps would you take to fix it?
ladessa [460]

Answer:

Assuming that TV was working fine and it stopped working when you restart or after power shutdown. Flat Black or blue screen or snow are all seems to be having HDMI cable sync issues. It can be fixed based on the model of the TV and connectivity it is using.

I would suggest to start with very basic step and should go step by step unless we narrow down the problem.

  1. <em>Turn off all the components, unplug the cables and plug them back by leaving HDMI cables intact. So this process will reset all the units and may help in renegotiation.</em>
  2. <em>Plug all the cables and Turn on the TV.  Plug all other components like sound receiver and source device and Turn on the power.  This may solve the problem.</em>
  3. <em>If issue still persist. Unplug and Plug back HDMI cables and surrounding components in HDMI path. It may solve the issue.</em>
  4. <em>If the issue still persists, then change the HDMI cable itself and try rebooting all components.</em>
  5. <em>If input is changed then it might have caused the issue. So identify the cable from the receiver to the TV.  figure out its input and change the TV input to that value and it will work.</em>
  6. <em>In some TV's if power reset happens, It may revert to TV mode then change the video input based on your TV model.</em>
  7. <em>If the receiver is connected to TV via Coax then change the channel as per TV guide.</em>
  8. <em>If the receiver and its component is using AV or HDMI then use TV remote to change the input source until correct feed is found.</em>
  9. <em>If issue still persist, check the cable with another TV and see if it works. If its not then cable is at fault.</em>
  10. <em>If the cable is fine then change the TV and try above steps.If it works then TV is at fault.</em>

Explanation:

7 0
3 years ago
Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2
Tamiku [17]

Answer:

import java.lang.*;

public class distance { public static double distance(double latitude1,

                                     double latitude2, double longitude1,

                                     double longitude2)

       {

      // Convert Latitude and Longitude to Radians

           longitude1 = Math.toRadians(longitude1);

           longitude2 = Math.toRadians(longitude2);

           latitude1 = Math.toRadians(latitude1);

           latitude2 = Math.toRadians(latitude2);

           

           double d_longitude = longitude2 - longitude1;

           double d_latitude = latitude2 - latitude1;

           double a = Math.pow(Math.sin(d_latitude / 2), 2)

                   + Math.cos(latitude1) * Math.cos(latitude2)

                   * Math.pow(Math.sin(d_longitude / 2),2);

           double val = 2 * Math.asin(Math.sqrt(a));

           // Radius of earth in kilometers is 6371

           double earth_radius = 6371;

           // Calculate and return the distance

           return(val * earth_radius);

       }

       // Main Method

       public static void main(String[] args)

       {

           double latitude1 = 67.32055555555556;

           double latitude2 = 83.31861111111111;

           double longitude1 = -1.7217899;

           double longitude2 = -1.6567799;

           System.out.println(distance(latitude1, latitude2,

                   longitude1, longitude2) + " K.M");

       }

   }

Explanation:

This program is implemented in Java programming language

The formula for the shortest distance between two points on the earth is:

Distance = 3963.0 * arccos[(sin(lat1) * sin(lat2)) + cos(lat1) * cos(lat2) * cos(long2 – long1)]

The latitude and longitude of the two points must be known

The latitude and longitude are converted into radians using built in methods in java.

Take value for the radius of the earth in Kilometers  6371;

Note that a seperate method has been created to calculate the distance

In the driver method (main), values for latitude and logitudes for both places have been hard-corded, then the method distance is called and passed those values

Note also that the distance has been calculated in Kilometers

8 0
3 years ago
What should be done if a system cannot boot from the hard drive?
White raven [17]
If the system cannot boot from the hard drive, then you should boot from the windows set-up dvd

I hope this helps! :)
3 0
3 years ago
Other questions:
  • you install teamviewer on your workstation at home so that you can ac ess it when on the road. how can you be assured that unkno
    9·1 answer
  • Which finger types the highlighted keys on a number keypad? A. Third B. First C. Pinky D. Thumb
    7·2 answers
  • How can I sent a message?
    13·1 answer
  • Wich technology can a website use to allow you to listen to a concert live over the internet?
    10·1 answer
  • The site is not allowing me to purchase the subscription. Please help?
    12·1 answer
  • HIPAA requires the following controls for medical records: A. Encryption of all data B. Technical safeguards C. Physical control
    12·1 answer
  • Fill in the blank: _________ is Google’s machine-learning artificial intelligence system that interprets people’s searches to fi
    9·1 answer
  • Do debit cards offer the highest level of fraud pretection?
    10·1 answer
  • This is the term for the manual process of editing strips of the film before digital editing was created. The term is still used
    9·1 answer
  • If Anyone can help me out that'll be great
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!