473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Program help

//Test 2 Question #23
#include<iostream>

using namespace std;
int main()
{
//variables defined here
float y, a, b, w, x, q, h, g;
char exit_variable;
int option;
cout<<"Please chose a program:\n";
cout<<"\n1. Y=10+((5*a)/((3*b)-(4*b*b)\n";
cout<<"\n2. w=(6*x*x*x*x*x)-15\n";
cout<<"\n3. q=(3/4)(h-(7*g)/6)\n";
cin>>option;
switch (option)
{case (1):
cout<<"\nEnter value for a ";
cin>>a;
cout<<"Enter value for b ";
cin>>b;
y=10+(5*a/(3*b))-(4*b*b);
cout<<"The answer is "<<y;
cout<<"When substituing into the equation Y=10+((5*";cout<<a;
cout<<")/((3*";cout<<b;
cout<<")-(4*";
cin>>b;
cout<<"*";
cin>>b;
cout<<")";
break;

case (2):
cout<<"Enter value for x";
cin>>x;
w=(6*x*x*x*x*x)-15;
cout<<"The answer is ";cin>>w;
cout<<"/nWhen substituting into the equation w=(6*";
cin>>x;
cout<<"*";cin>>x;
cout<<"*";
cin>>x;
cout<<"*";
cin>>x;
cout<<")-15";

break;

case (3):
cout<<"Enter value for h";
cin>>h;
q=(3/4)*(h-(7*g)/6);
cout<<"The answer is";cin>>q;
cout<<"When substituting into the equation q=(3/4)(";
cin>>h;cout<<"-(7*";
cin>>g;
cout<<")/6)";
break;
}

[/code] cin>>exit_variable;

}

what needs fixing ? :)
I got a bit further this time. I don't know what you mean by /code.
I need the program to calculate the 3 equations and output the answer and output what was inputed.
for example, it should say answer = #
and then input for a value was # and input for B value was #
Oct 31 '08 #1
6 1298
boxfish
469 Expert 256MB
What's it supposed to do and what's wrong with it? If you are getting errors, please post them here. Also, please use code tags around your code. Put [CODE] before it and [/CODE] after it so it shows up in a code box and the indentation isn't wrecked. Thanks.
Oct 31 '08 #2
boxfish
469 Expert 256MB
You have the parentheses wrong somewhere, and you have a problem with integer division.
3.0 / 4.0 is 0.75
3 / 4.0 is 0.75
3.0 / 4 is 0.75
but
3 / 4 is 0. When you divide an integer by another integer, the result is rounded down to a whole number. Don't divide two integers unless you know what you are doing. After you fix these things, I think your program will work.
Here's how code tags are supposed to be used:
[CODE]
int main() {
// Example code.
return 0;
}
[/CODE]
And when you post it, it will look like this:
Expand|Select|Wrap|Line Numbers
  1. int main() {
  2.     // Example code.
  3.     return 0;
  4. }
  5.  
Hope this helps.
Oct 31 '08 #3
so how do i say 3/4?
Oct 31 '08 #4
r035198x
13,262 8TB
so how do i say 3/4?
Did you read box's response above?
Oct 31 '08 #5
boxfish
469 Expert 256MB
Why not just use 0.75 in your program?
Oct 31 '08 #6
could we delete this post plz
Oct 31 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: atlanta | last post by:
this is a simple C++ program to write. "Write a complete and functioning structured program that successfully compiles on Visual C++ 6, that uses two-dimensional array (5x5) that stores...
4
by: Josh | last post by:
Howdy i am newb somewhat to programing and i was just for fun trying to compile a program that asks the user for an odd int less than 22 and then returns this ***************** ******* *********...
34
by: John Harrison | last post by:
An odd confession; an odd request; but here's the tale.... My company has a few PC systems which we have used for about 7 years and not updated - we've "made do", and besides, "if it ain't...
5
by: Nikola | last post by:
I need to write a program that generates 5 random numbers and puts them into a linked list. (Print the list) From that list it forms another list in a way if the arrangement of elements in the...
9
by: santoshp80 | last post by:
Hi All, Can anybody help me for these programs. I need to submit ny assignments. 1) Write a C++ program to generate Lucas series 2) Write a C++ program to accept the student's information...
2
by: zaidalin79 | last post by:
Here is my Inventory program for my Java class.... //Inventory.java //Class created to store item information for Inventory purposes //Created November 15, 2006 //Modified November 29, 2006...
4
by: saggie | last post by:
I cannot write this C program that uses a function to calculate the area of a circle, witha circle's circumference. This function (findArea) should call a second function (findRadius) which will...
8
by: Jrezak321 | last post by:
Hi I was wondering if anyone could help me with this homework problem of mine? I need to create a program that does this: Write a program that plays “guess the number” as follows: Your program...
1
by: Sleepwalker817 | last post by:
Hello, I am trying to create a program that is supposed to calculate and print the average of several grades entered by the user. The output is supposed to look something like this:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.