|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming | |
Can someone write a basic code for me?
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#11 (permalink) | |||||||||
|
Oͪͭ͏͝͏̘̳v̙͖ͥ̑̃ͨ̅ê̅ͥ͒̚ ̊ͬ͟
![]() |
I could do it. But cba :/
__________________
|
|||||||||
|
|
|
|
#12 (permalink) | |||||||||||||
|
4.0 GHz
![]()
Join Date: Aug 2007
Location: The darkness of your mind
Posts: 785
Rep: 49
![]() Unique Rep: 46
Trader Rating: 4
|
Here's the code if you, or someone else can compile it.
Code:
#include <iostream>
using namespace std;
int main()
{
char type=' ';
double tempC=0.0;
double tempF=0.0;
double tempK=0.0;
double totTemp=0.0;
double gir=0.0;
sel:
cout << "Please select input temp type (F, C, K): ";
cin >> type;
switch (type)
{
case 'F':
goto fah;
break;
case 'f':
goto fah;
break;
case 'C':
goto cel;
break;
case 'c':
goto cel;
break;
case 'K':
goto kel;
break;
case 'k':
goto kel;
break;
default:
cout << "Invalid input type." <<endl;
goto sel;
break;
}
fah:
cout << "Please enter temp: ";
cin >> tempF;
tempC=((5/9)*(tempF-32));
tempK=(tempC+273.15);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
goto end;
cel:
cout << "Please enter temp: ";
cin >> tempC;
tempF=(((9/5)*tempC)+32);
tempK=(tempC+273.15);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
goto end;
kel:
cout << "Please enter temp: ";
cin >> tempK;
tempC=(tempK-273.15);
tempF=(((9/5)*tempC)+32);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
goto end;
end:
cout <<endl;
cout << "Girs= " << gir <<endl<<endl;
return(0);
}
|
|||||||||||||
|
|
|
|
|
#13 (permalink) | ||||||||||||||
|
Mobo Master
![]() |
Quote:
![]() Not gonna complain you finished before i did.
__________________
Electrical Engineering and Computer Science Student (Joint Bsc Hons) STUDENT FINANCE HURRY UP!!! Has far to many components for a 20 year old, and while you're at it forgive my spelling, the keyboard is dyslexic
|
||||||||||||||
|
|
|
|
|
#14 (permalink) | ||||||||||||||
|
4.0 GHz
![]()
Join Date: Dec 2008
Location: Ghettoshiels in Scotland
Posts: 4,986
Rep: 703
![]() ![]() ![]() ![]() ![]() ![]() ![]() Unique Rep: 503
Trader Rating: 11
|
Ah, so much win.
Thanks for you sir. + ![]() I'm not even sure how to use it, but thanks. >.< meticadpa is a programming noob.
__________________
Quote:
The more you love music, the more music you love. ~aaronman
|
||||||||||||||
|
|
|
|
|
#15 (permalink) | |||||||||||||
|
4.0 GHz
![]()
Join Date: Aug 2007
Location: The darkness of your mind
Posts: 785
Rep: 49
![]() Unique Rep: 46
Trader Rating: 4
|
LOL, all that matters is that it works!
|
|||||||||||||
|
|
|
|
|
#16 (permalink) | |||||||||||||
|
Mobo Master
![]() |
Well this is mine(in C#). Takes any value in Degrees C and give it in Girs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string DegreesCString;
double DegreesC, failedInput, DegreesF, DegreesK, DegreesGir, tottemp;
failedInput = 0;
do
{
Console.WriteLine("Please enter tempurature in Degrees C");
DegreesCString = Console.ReadLine();
try
{
DegreesC = Convert.ToDouble(DegreesCString);
failedInput = 0;
}
catch
{
Console.WriteLine("Not a valid input. Try again");
failedInput = 1;
DegreesC = 0;
}
} while (failedInput == 1);
DegreesF = (((DegreesC * 9)/5) + 32);
DegreesK = (DegreesC + 273.15);
tottemp = ((DegreesC + DegreesF + DegreesK) / 3);
DegreesGir = (tottemp * 89875517900000000);
Console.WriteLine(" {0} Degrees C equals {1}Girs", DegreesC, DegreesGir);
Console.WriteLine("Press any key when Finished");
Console.ReadLine();
}
}
}
__________________
Electrical Engineering and Computer Science Student (Joint Bsc Hons) STUDENT FINANCE HURRY UP!!! Has far to many components for a 20 year old, and while you're at it forgive my spelling, the keyboard is dyslexic
Last edited by Starbuck5000 : 2 Weeks Ago at 11:45 AM |
|||||||||||||
|
|
|
|
|
#17 (permalink) | |||||||||||||
|
4.0 GHz
![]()
Join Date: Aug 2007
Location: The darkness of your mind
Posts: 785
Rep: 49
![]() Unique Rep: 46
Trader Rating: 4
|
Yeah, yours definitely looks more elegant
(even though I don't know any C# lol) Cleaned mine up a bit: Code:
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char type=' ';
double tempC=0.0;
double tempF=0.0;
double tempK=0.0;
double totTemp=0.0;
double gir=0.0;
cout << "Please select input temp type (F, C, K): ";
cin >> type;
type=static_cast<char>(toupper(type));
if(type=='F')
{
cout << "Please enter temp: ";
cin >> tempF;
tempC=((5/9)*(tempF-32));
tempK=(tempC+273.15);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
}
else if(type=='C')
{
cout << "Please enter temp: ";
cin >> tempC;
tempF=(((9/5)*tempC)+32);
tempK=(tempC+273.15);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
}
else if(type=='K')
{
cout << "Please enter temp: ";
cin >> tempK;
tempC=(tempK-273.15);
tempF=(((9/5)*tempC)+32);
totTemp=(tempC+tempF+tempK);
gir=((totTemp/3)*(89875517900000000));
}
else
cout << "Invalid Input type." <<endl;
cout <<endl;
cout << "Girs= " << gir <<endl<<endl;
return(0);
}
Last edited by 31337 : 2 Weeks Ago at 11:55 AM |
|||||||||||||
|
|
|
|
|
#18 (permalink) | ||||||||||||
|
AMD Overclocker
![]() |
cLISP.
![]() Code:
(defun cg (X) "Convert Celcius to Girs." (* (/ (+ (* (/ 9 5) (+ X 32)) X (+ X 273.15)) 3) 89875517900000000)) Get it here. Run and type Code:
(load "cg") (cg value)
__________________
Last edited by MadCatMk2 : 2 Weeks Ago at 12:39 PM |
||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|