// Kinetic energy #include <iostream.h> #include <conio.h> #include <fstream.h> void main () { double long Mass, Speed, KE ; cout << "What is the mass?\n" ; cin >> Mass ; cout << "What is the speed?\n" ; cin >> Speed ; KE = Speed * Speed * Mass / 2 ; ofstream printObject ; printObject .open ("h:\\C++\\KE.txt" , ios::out ) ; cout << "The kinetic energy is..." << KE << endl ; printObject << "Speed..." << Speed << endl ; printObject << "Mass..." << Mass << endl ; printObject << "Total kinetic energy..." << KE << endl ; printObject .close (); cout << " Press any key to end run..." ; getch () ; } Farenheit to celsius converter:// CP1, Farenheit to celsius program #include <conio.h> #include <iostream.h> #include <fstream.h> void main () { double long C, F ; cout << "Please enter fahrenheit temperature. \n" ; cin >> F ; C = (F - 32)* 5/9 ; ofstream printObject ; printObject .open ("h:\\C++\\Farenheitconverter.txt" , ios::out ) ; cout << "Your degrees in celsius is " << C <<endl ; printObject << "Your degrees in celsius is " << C <<endl ; cout << "Press any key to end run..." ; getch () ; } Finds your gross pay and net pay after a tax deduction of 20%, also input your number of hours worked and rate of payment.// Payment #include <iostream.h> #include <conio.h> #include <fstream.h> void main () { double long Rate, Hours, Gross, Withheld, Netpay ; cout << "Please enter Hours worked.\n" ; cin >> Hours ; cout << "Please enter Rate of payment.\n" ; cin >> Rate ; Gross = Rate * Hours ; Withheld = Gross * .20 ; Netpay = Gross - Withheld ; ofstream printObject ; printObject .open ("h:\\C++\\Payment.txt" , ios::out ) ; cout << "You worked...Hours = "<< Hours << endl ; cout << "You make ... an hour " << Rate << endl ; cout << "Gross pay = " << Gross << endl ; cout << "Withheld = " <<Withheld << endl ; cout << "Netpay = " << Netpay << endl ; printObject << "Gross pay = " << Gross << endl ; printObject << "Amount of money taken by taxes = " << Withheld << endl ; printObject << "Money made after taxes = " << Netpay << endl ; printObject .close (); cout << " Press any key to end run..." ; getch () ; }
mass = input("What is the mass ? ") ; mas = float(mass)speed = input("What is the speed ? ") ; sped = float(speed)energy = sped * sped * mas / 2print ("Kinetic energy =", int(energy))b = input ("Press enter to exit : ")
I call your C++ and raise you a python.Code: [Select]mass = input("What is the mass ? ") ; mas = float(mass)speed = input("What is the speed ? ") ; sped = float(speed)energy = sped * sped * mas / 2print ("Kinetic energy =", int(energy))b = input ("Press enter to exit : ")
public class Think{ public static void main(String[] args){ Actions myActionObj = new Actions(); myActionObj.displayMessage("Hello World!"); }}
public class Actions{ public void displayMessage(String msg){ System.out.println(msg); }}
Idk about python but in c++ you still have to spell the variables in your formula correctenergy = speed * speed * mass / 2Corrected
mass = input("What is the mass ? ") ; [b]mas = float(mass)[/b]speed = input("What is the speed ? ") ; [b]sped = float(speed)[/b]
#include <iostream>using namespace std;int main(){ cout << "Hello world!" << endl; return 0;}
I can't seem to get my C++ code to work, I have no idea how to compile it. Can anyone help?
Quote from: Meatwad on September 29, 2011, 07:33:31 PMI can't seem to get my C++ code to work, I have no idea how to compile it. Can anyone help?Download an IDE like Code::Blocks.http://www.codeblocks.org/downloadsStart a new project, put it in the typing area, and compile it.