1 2 Previous Next 22 Replies Latest reply: Dec 13, 2007 3:24 PM by 807601 RSS

    How to change a java file to a C++ file.

    807601
      Hi can someone plese tell me how i can change a java file into a c++ file. what do i need to change on the coe below:

      import javax.swing.* ;

      class Sentinel
      {
      public static void main( String[] args )
      {     
      double total = 0.0 ;
      int count = 0, datum = 0 ;

      String strDatum = JOptionPane.showInputDialog( "Enter datum - a negative value to terminate:" ) ;
      datum = Integer.parseInt( strDatum ) ;

      while ( datum >= 0 )
      {
      total+= datum ;
      count++ ;
      strDatum = JOptionPane.showInputDialog( "Enter next datum - a negative value to terminate:" ) ;
      datum = Integer.parseInt( strDatum ) ;
      }

      if ( count > 0 )
      {
      System.out.println( "Average = " + total/count ) ;
      }
      else
      {
      System.out.println( "No valid data entered" ) ;
      }
      System.exit(0) ;
      }
      }
        1 2 Previous Next