*The solution needs to be in one file
Since there are no languages specified, Let me solve this using
c++.
Code:
#include <iostream>
#include<math.h>
using namespace std;
class Gravity{
public:
float f,g,m1,m2,r;
Gravity()
{
g=6.673*pow(10,-11);
cout<<"\n\n\nEnter the values of m1 and m2 (in KG): ";
cin>>m1>>m2;
cout<<"\nEnter the value of r (in m): ";
cin>>r;
cout<<"\nForce = "<<(g*m1*m2)/(r*r)<<" N ";
}
};
int main()
{
int forces[100],mass,n,x,fsum=0;
cout<<"\nEnter number of forces: ";
cin>>n;
cout<<"\nEnter the values of forces (in N): ";
for(int i=0;i<n;i++)
{
cin>>forces[i];
fsum=fsum+forces[i];
}
cout<<"\nThe forces entered are: ";
for(int i=0;i<n;i++)
{
cout<<forces[i]<<" N, ";
}
cout<<"\nEnter the value of mass (in KG): ";
cin>>mass;
cout<<"\nAbsolute acceleration: "<<(float)fsum/mass<<" ms^-2";
Gravity obj;
return 0;
}
Output:
*The solution needs to be in one file Newton's 2nd Laws: The absolute acceleration of a...
Q3) A day has 86,400 secs (24*60*60). Given a number in the range 1 to 86,400, output the current time as hours, minutes, and seconds with a 24-hour clock. For example:70,000 sec is 19 hours, 26 minutes, and 40 seconds. Q4) Consider a triangle with sides of length 3, 7, and 9. The law of cosines states that given three sides of a triangle (a, b, and c) and the angle C between sides a and b: c square = a...
For this program you will build a modular equation evaluator (you may want to start from your solution to programming assignment 1). Once again, you will write a C program that evaluates the equations provided below. The program must prompt the user for inputs for the equations and evaluate them based on the inputs. All equations should be placed into a single .c file. This means you should NOT have 7 Visual Studio projects or 7 .c files. All variables...
Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...
Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...
The file containing the JAVA files, pseudocode file and doc file that have written for this lab. Preamble The file releasedates.txt contains a list of video games and their release dates. Each line of the file contains the release date, a tab character, and then the name. The list is currently totally unsorted. The object of today's lab is to write a series of methods that allow us to perform the following tasks: read contents from a file and store...
Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...