Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Nithin N.
Tutoring students of my locality for the past 6 years
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

Write a program to compute the sum, average, maximum and minimum of elements in an array.

Nithin N.
Answer:

package example; import java.util.Scanner; public class JavaProgram { public static void main(String[] args) { int n; int ch=0; float avg = 0; Scanner s = new Scanner(System.in); System.out.println("Enter your option:\n1. Sum of elements of the array"); System.out.println("2. Average of array\n3. Maximum\n4. Minimum\n5. Exit"); ch = s.nextInt(); System.out.print("Enter no. of elements you want in array:"); n = s.nextInt(); int a[] = new int[n]; System.out.println("Enter all the elements:"); for(int i = 0; i < n ; i++) a[i]=s.nextInt(); if(ch==1) { int total=0; for(int i=0; i<a.length;i++) total=total+a[i]; System.out.println("Sum of elements of the array = "+total); } else if(ch==2) { int total=0; for(int i=0; i<a.length;i++) total=total+a[i]; total=total/a.length; System.out.println("Average of elements of the array = "+total); } else if(ch==3) { int max = a[0]; for (int i = 0; i < a.length; i++) { if (a[i] > max) { max = a[i]; } } System.out.println("Maximum of elements of the array = "+max); } else if(ch==4) { int min = a[0]; for (int i = 0; i < a.length; i++) { if (a[i] < min) { min = a[i]; } } System.out.println("Minimum of elements of the array = "+min); } } }

Basic Math
TutorMe
Question:

Out of 7 consonants and 4 vowels, how many words of 3 consonants and 2 vowels can be formed?

Nithin N.
Answer:

Number of ways of selecting 3 consonants from 7 = 7C3 Number of ways of selecting 2 vowels from 4 = 4C2 Number of ways of selecting 3 consonants from 7 and 2 vowels from 4 = 7C3 × 4C2 =(7×6×5/3×2×1)×(4×3/2×1)=210 It means we can have 210 groups where each group contains total 5 letters (3 consonants and 2 vowels). Number of ways of arranging 5 letters among themselves =5!=5×4×3×2×1=120 Hence, required number of ways =210×120 =25200

C++ Programming
TutorMe
Question:

Write a program to compute the standard deviation and Average of n numbers read from a file whose name is input in the program.

Nithin N.
Answer:

#include <iostream> #include <fstream> #include <string> #include <cmath> using namespace std; int main() { ifstream input; double number, sum = 0.0; double average, standardDeviation = 0.0; double *arr; int count = 0, i = 0; int flag=0; string file_name; while(flag!=3) { cout << "Enter the file name: "; cin >> file_name; //Open the input file input.open(file_name.c_str()); if (!input) { cout << "File not found!!!" << endl; flag++; } else { while (input >> number) { count++; } input.close(); arr = new double[count]; input.open(file_name.c_str()); while (input >> number) { sum += number; arr[i] = number; i++; } average = sum / count; for (int j = 0; j < count; ++j) { standardDeviation += pow((arr[j]-average), 2); } standardDeviation = sqrt(standardDeviation / count); cout << "The average is: " << average << endl; cout << "The standard deviation is: " << standardDeviation << endl; input.close(); return 0; } } }

Send a message explaining your
needs and Nithin will reply soon.
Contact Nithin
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.