Make a struct LINE include appropriate data members.
A line segment includes the endpoints, i.e. the points that it joins.
structure should also provide a function to find the length of the Line
Two lines can be compared to determine which line is shorter and vice versa. Provide function to compare two Lines
Provide appropriate constructors for initialization.
Create a struct point to represent a point in cartesian coordinate system
provide member functions
default constructor
input
output
distance(returns the distance between two point objects, the function takes one object as an argument)
is zero(determines if a point is the center)
midlepoint (computes the middle point of an object from origin and returns the answer in a point object)
is equal to(compare two points)
isGreater than (compares two point in terms of the distance from the center)
Previous lesson displays static information. In this lesson we are going to use the dynamic display of information. #include <iostream> using namespace std; int main(){ //we declare data types here. string name; //fist we need to display the Instruction for the user."Enter your name: cout<<"Enter your name: //we call the "name" variable to get the user input. we use "cin" to get the user input cin>>name; //we call again our variable name to display what the user input. cout<<"Your name is: "<<name; //try it and try to complete the personal information. add the following variables //age, gender, address, email, mobile }
Hello!
I am trying to find how many jelly beans can fit in a jar. so I made some variables.
double height, diameter, beanLength, beanDiameter, glassThickness, radius, newRadius;
double volumeOfJar, airCubicInches, trueVolume, jellyBeanVolume;
as show here. But I need to initialize them. so I tried this
int height;
int diameter;
int beanLength; beanLength = 0.625;
int beanDiameter; beanDiameter = 0.25;
int glassThickness;
int radius;
int newRadius;
int volumeOfJar;
int airCubicInches;
int trueVolume;
int jellyBeanVolume;
But my program does not like that. How do I fix the varibles to be initialized?
diameter of a cycle wheel is D. Given that, the cycle travels at an average speed of X km/h,
find the number of revolutions made by the wheel per minute, giving your answer to the nearest whole
number (assume PI = 3.142). Write a C++ function to calculate revolutions per minute.
The diameter of a cycle wheel is D. Given that, the cycle travels at an average speed of X km/h,
find the number of revolutions made by the wheel per minute, giving your answer to the nearest whole
number (assume PI = 3.142). Write a C++ function to calculate revolutions per minute.
Assume a file named
Random.txt
exists, and contains a list of random numbers. Write a program that opens the file, reads all the numbers from the file, and calculates the following:
The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers.
Output Labels:
Print each of the above quantities on a line by itself, preceded by the following (respective) strings: "
Number of numbers:
", "
Sum of the numbers:
", and "
Average of the numbers:
".
Sample Run
Number of numbers: 20
Sum of the numbers: 210
Average of the numbers: 10.5