Rectangle 27 2

Here is what might help you : leave blank the text field which you want to be populated( leave blank fahrenheit if you want to convert from celsius to fahrenheit ).

@Override
public void actionPerformed(final ActionEvent e) {
    double celsius = 0, fahrenheit = 0;
    DecimalFormat twoDigits = new DecimalFormat("0.00");
    if (Temperature_Converter.this.TFCelsius.getText() == null || "".equals(Temperature_Converter.this.TFCelsius.getText().trim())) {
        // convert from fahrenheit to celsius
        fahrenheit = Double.parseDouble(Temperature_Converter.this.TFFahrenheit.getText());
        celsius = (fahrenheit - Temperature_Converter.offset) *   Temperature_Converter.FahrenheitTOCelsius;
        Temperature_Converter.this.TFCelsius.setText(" " + twoDigits.format(celsius));
    } else if (Temperature_Converter.this.TFFahrenheit.getText() == null || "".equals(Temperature_Converter.this.TFFahrenheit.getText().trim())) {
           // convert from celsius to fahrenheit
           celsius = Double.parseDouble(Temperature_Converter.this.TFCelsius.getText());
           fahrenheit = celsius * Temperature_Converter.CelsiusTOFarenheit + Temperature_Converter.offset;
           Temperature_Converter.this.TFFahrenheit.setText(" " + twoDigits.format(fahrenheit));
    }
}

Edit : You can validate the user input text and alert the user if there are something else then numbers introduced as a temperature.

try {
    fahrenheit = Double.parseDouble(Temperature_Converter.this.TFFahrenheit.getText());
} catch (NumberFormatException e1) {
     //alert the user       
    JOptionPane.showMessageDialog(null, "You are allowed to introduce numbers only for temperature");
    return;
}

This was great. It fixed my issue completely. I knew there should have been an if statement somewhere I just didn't know how to go about it. My CS logic is still not the best. Thanks!

@Mowza2k2 you are developing your CS logic by doing this kind of problems. Keep going on and you will advance a lot. By the way , watch the edit part of the post for user friendly alert message.

thank you so much. Everything you posted made sense to me, though I didn't know how to go about it myself. It's nice to have somewhere to go where I can get some help (without bugging my professor).

@Mowza2k2 you are very welcome. I'm happy you feel welcome in the community and that you find your answers here.

user interface - Java GUI Fahrenheit/Celsius Converter with a Button -...

java user-interface temperature
Rectangle 27 1

Assuming that I have to put one value in the Fahrenheit field and one in the Celsius field and they should be calculated at the same time, you have to kind of "cache" your calculation values in other variables than the ones you got from the textfields.

the result of your first calculation (the new Celsius value) will be used in the second calculation, leading to the very same result as the value in the Fahrenheit field originally was (because it just converts the value to Celsius and than back again)

The solution for your problem is to safe your results in new variables like:

celsius = Double.parseDouble(TFCelsius.getText());
fahrenheit = Double.parseDouble(TFFahrenheit.getText());
double celsiusNew = (fahrenheit - offset) * FahrenheitTOCelsius;
double fahrenheitNew = celsius * CelsiusTOFarenheit + offset;
TFCelsius.setText(" "+ twoDigits.format(celsiusNew));
TFFahrenheit.setText(" "+ twoDigits.format(fahrenheitNew));

Edit: read the other two answers as well for making your program more user-friendly and bulletproof.

Thanks a ton. Alongside the other text it all works great.

user interface - Java GUI Fahrenheit/Celsius Converter with a Button -...

java user-interface temperature
Rectangle 27 1

Ignoring the code issues that make the example uncompliable...

You have an integer division problem...

celsius = (5 / 9) * (fahrenheit - 32);

If 5/9 = 0 as the resulting value is converted to an integer.

celsius = Math.round((5 / (float)9)) * (fahrenheit - 32);

Now, personally, I would be using a double or float instead of an int and formatting the result but that's me. You'll need to do the same thing FahrenheitButtonHandler

In your FahrenheitButtonHandler class, you are also applying the wrong value to the text field...

celsius1 = Integer.parseInt(fldFahrenheit.getText());
fahrenheit1 = celsius1*(9/5)+32;
fldCelsius.setText(celsius1.toString());

You applying the celsius1 value, which is the value your extract from the fldFahrenheit field, not the calculated result, it should be

fldCelsius.setText(fahrenheit1.toString());

...but remember, there is still the interger division problem you need to correct for this...

ActionListener
btnFahrenheit
FahrenheitButtonHandler btnHandlerFahrenheit = new FahrenheitButtonHandler();
btnFahrenheit.addActionListener(btnHandlerFahrenheit);

java - Celsius to Fahrenheit Converter GUI program - Stack Overflow

java swing user-interface jframe
Rectangle 27 1

i think that your problem with The text Field ,if you didn't input numbers in the two text fields you will get "empty String" problem which cannot convert it to Double , so you need to check that you string not equal to empty

celsius = Double.parseDouble(TFCelsius.getText());
 fahrenheit = Double.parseDouble(TFFahrenheit.getText());

to solve it , you can make like this , For Example :

if (!TFCelsius.getText().equals("")) {
     celsius = Double.parseDouble(TFCelsius.getText());
 } else {
     ////i don't know what the value but make it equal 0
 }

user interface - Java GUI Fahrenheit/Celsius Converter with a Button -...

java user-interface temperature
Rectangle 27 21

enscript
source-highlight

The first can output to PostScript (that you can convert to PDF using ps2pdf), the second produces output in HTML, LaTeX and other formats.

EDIT: On my system the following command will print all the cpp files in the current subtree.

find . -name "*.cpp" | xargs enscript -Ecpp -fCourier8

While the following will produce a code.pdf file with the same content

PS: and give the --color=1 for color output and -C for line numbers.

find . -name "*.cpp" | xargs enscript --color=1 -C -Ecpp -fCourier8 -o - | ps2pdf - code.pdf

enscript uses default media size A4. If you want to use letter size, add -M Letter to the enscript options.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

Is there a command line C++ to PDF converter with syntax highlighting?...

c++ pdf documentation syntax-highlighting
Rectangle 27 3

H2Pas is a popular tool to convert C headers to Pascal. I don't know of any to actually convert C code to Pascal code though.

From a quick google search, I see several that may or may not be good:

I am tempted to say you'll have to do a lot of it by hand one way or another.

Yeah, tried c2pas, but might as well write the program in pascal from scratch than use that. It may work for dead simple programs though.

Java/C/C++/C#/PHP to Pascal converter? - Stack Overflow

java c++ c delphi pascal
Rectangle 27 3

I use this. It generates .ps. Then you can run ps2pdf.

# Copyright 2004 Rutger E.W. van Beusekom.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

outfile=$1
shift

a2ps -1 --highlight=normal --pretty-print=cxx --line-numbers=1 -M a4 -L80 -g \
-o $outfile $* --prologue=color --right-title=%p. --left-title \
--left-footer --right-footer --header --medium=a4

You could also use Doxygen with source browsing enabled. There is also htmlize.el by Hrvoje Niksic for emacs.

Is there a command line C++ to PDF converter with syntax highlighting?...

c++ pdf documentation syntax-highlighting
Rectangle 27 2

imshow() thinks, the Matrix is in BGR order. Converting the image to HSV just converts the RGB values to HSV channel values.

It was before 3 channel and after the conversion it is also 3 channel but other values. imshow() still wants to display the image as RGB image but then with HSV values which leads to an invalid image.

imshow()
Mat hsv, bgr; // hsv is the hsv image you want to display
cvtColor(hsv, bgr, CV_HSV2BGR);
imshow("lolz", bgr);

opencv - How to display HSV image after using RGBtoHSV converter funct...

c++ opencv hsv
Rectangle 27 1

Biggest time saver tip for header conversion from C is to find a VB header and convert it with VB converter mentioned in other answer. This was almost always fully automated and changes I had to make were none or minor!

Java/C/C++/C#/PHP to Pascal converter? - Stack Overflow

java c++ c delphi pascal
Rectangle 27 1

There was released Android2DelphiImport tool a short time ago. This tool is designed for XE5, and automates the import unit writing by generating a pascal wrapper unit from jar. It is a commercial package. Here are another two similar tools - Utility to generate Java Android class and jar file interfaces for Delphi XE5 Firemonkey ('JavaToPas' and 'JavaImport For Android').

Java/C/C++/C#/PHP to Pascal converter? - Stack Overflow

java c++ c delphi pascal
Rectangle 27 3

int main()
{
    char buff[1024] = {0};
    FILE* cvt;
    int status;
    /* Launch converter and open a pipe through which the parent will write to it */
    cvt = popen("converter", "w");
    if (!cvt)
    {
        printf("couldn't open a pipe; quitting\n");
        exit(1)
    }
    printf("enter Fahrenheit degrees: " );
    fgets(buff, sizeof (buff), stdin); /*read user's input */
    /* Send expression to converter for evaluation */
    fprintf(cvt, "%s\n", buff);
    fflush(cvt);
    /* Close pipe to converter and wait for it to exit */
    status=pclose(cvt);
    /* Check the exit status of pclose() */
    if (!WIFEXITED(status))
        printf("error on closing the pipe\n");
    return 0;
}

The important steps in this program are:

  • The popen() call which establishes the association between a child process and a pipe in the parent.
  • The fprintf() call that uses the pipe as an ordinary file to write to the child process's stdin or read from its stdout.
  • The pclose() call that closes the pipe and causes the child process to terminate.

I think this example misses the point of the question, although I grant that the "converter" program is a different program. The first comment addresses communication between completely independent programs that do not have a sibling/parent/second-cousin relationship.

c - How to send a simple string between two programs using pipes? - St...

c unix pipe
Rectangle 27 0

i think that your problem with The text Field ,if you didn't input numbers in the two text fields you will get "empty String" problem which cannot convert it to Double , so you need to check that you string not equal to empty

celsius = Double.parseDouble(TFCelsius.getText());
 fahrenheit = Double.parseDouble(TFFahrenheit.getText());

to solve it , you can make like this , For Example :

if (!TFCelsius.getText().equals("")) {
     celsius = Double.parseDouble(TFCelsius.getText());
 } else {
     ////i don't know what the value but make it equal 0
 }

user interface - Java GUI Fahrenheit/Celsius Converter with a Button -...

java user-interface temperature
Rectangle 27 0

Assuming that I have to put one value in the Fahrenheit field and one in the Celsius field and they should be calculated at the same time, you have to kind of "cache" your calculation values in other variables than the ones you got from the textfields.

the result of your first calculation (the new Celsius value) will be used in the second calculation, leading to the very same result as the value in the Fahrenheit field originally was (because it just converts the value to Celsius and than back again)

The solution for your problem is to safe your results in new variables like:

celsius = Double.parseDouble(TFCelsius.getText());
fahrenheit = Double.parseDouble(TFFahrenheit.getText());
double celsiusNew = (fahrenheit - offset) * FahrenheitTOCelsius;
double fahrenheitNew = celsius * CelsiusTOFarenheit + offset;
TFCelsius.setText(" "+ twoDigits.format(celsiusNew));
TFFahrenheit.setText(" "+ twoDigits.format(fahrenheitNew));

Edit: read the other two answers as well for making your program more user-friendly and bulletproof.

Thanks a ton. Alongside the other text it all works great.

user interface - Java GUI Fahrenheit/Celsius Converter with a Button -...

java user-interface temperature
Rectangle 27 0

There is no converter, but You may take a look at Haxe. It's multi-platform open source language that can be compiled into other languages, including C#. The syntax is similar to PHP.

php to C# converter - Stack Overflow

c# php
Rectangle 27 0

Take a look at iTextSharp. It is a C# port of iText. It is licensed under the AGPL v3. It should be able to pull out the text for you.

I have this library! Is any examples how to get text or images from pdf?

iTextSharp (versions after 5.0) may be not that free as one may think. See itextpdf.com/terms-of-use for more info.

Yes it is definitely important to understand the terms of the AGPLv3. It often requires publishing your source code, among other things, if you wish to use the iText stuff freely.

.net - C# pdf to text converter - Stack Overflow

c# .net pdf
Rectangle 27 0

To create a TypeConverter, simply create a class that inherits from TypeConverter. Then you use the TypeConverterAttribute to tag your class, so that anytime someone tries a convert operation on your class, your TypeConverter is invoked.

Once you inherit from TypeConverter, you should override some of its methods to do what you want. You'd probably want to look at ConvertFrom(), ConvertTo(), and ConvertToString() to start with - that's where you would implement the logic to pull out your localized version of your strings.

var foo = TypeDescriptor.GetConverter(typeof(T));
var mystring = foo.ConvertToString(myObject));

MSDN of course has the documentation and some examples of TypeConverter implementation.

But how do you do the conversion?

localization - C#: How to use a Type Converter to localize enums - Sta...

c# localization enums typeconverter
Rectangle 27 0

Also, you could combine this with an extension method for enums with a name like ToDisplayString.

localization - C#: How to use a Type Converter to localize enums - Sta...

c# localization enums typeconverter
Rectangle 27 0

c2f converter [C++]

#include <iostream>

int main ()
{
  std::cout << "welcome to our celsius to farenheit converter!"<<std::endl;
std::string abc;  
int cel;
int far;

do
{
  std::cout << "what is your temparature in celsius?" <<std::endl;

  std::cin >> cel  ;
  far= 32+(1.8*cel);
  std::cout << "your temperature in farenheit is "<<far<<"" <<std::endl;
  std::cout <<"do you want to input another value? y/n" <<std::endl;
  std::cin>>abc;

}while(abc=="y");
std::cout << "thanks for using our converter, have a nice day";
    return 0;
}
C++
Rectangle 27 0

C to F converter [C++]

#include <iostream>

int main ()
{
   int temp;
   std::cout << "Welcome to our Celsius to Fahrenheit converter " << std::endl;
while(true) {
   std::string yorn;
   std::cout << "What is your temperate in Celsius? ";
   std::cin >> temp;
   std::cout << "Your temperature in Fahrenheit is ";
   std::cout << temp * 1.8 + 32;
   std::cout << std::endl << "Do you want to input another temperature (y/n)? ";
   std::cin >> yorn;
   if (yorn == "n") {
     std::cout << "Thank you for using the Celsius to Fahrenheit converter";
     
     break;
     
   }
}
return 0;
}
C++
Rectangle 27 0

Fahrenheit to Celsius converter [C++]

#include <iostream>
#include <string>

int main ()
{
  std::string yOrn;
  yOrn = "y";
  double Fahrenheit;
  double Celsius;
  while (yOrn == "y")
  {
  std::cout << "Please enter a temperature in degrees Fahrenehit: " << std::endl;
  std::cin >> Fahrenheit;
  Celsius = (Fahrenheit-32)*.5556;
  std::cout << "Your temperature in degrees Celsius is: " << Celsius << std::endl;
  std::cout << "Would you like to do this again? (y/n) " << std::endl;
  std::cin >> yOrn;
  }
  return 0;
  
  
  
}
C++