public class GlobalMembers
{
static int Main()
{
menukar angka = new menukar();
angka.swap();
getch();
return 0;
}
}
public class menukar
{
public final void swap()
{
System.out.print("masukkan a :");
a = SimulateCin.readToWhiteSpace(true);
System.out.print("masukkan b :");
b = SimulateCin.readToWhiteSpace(true);
System.out.print("a=");
System.out.print(a);
System.out.print(",b=");
System.out.print(b);
System.out.print("\n");
System.out.print("b=");
System.out.print(b);
System.out.print(",a=");
System.out.print(a);
System.out.print("\n");
}
private int a;
private int b;
}
//----------------------------------------------------------------------------------------
// Copyright © 2006 - 2009 Tangible Software Solutions Inc.
//
// This class provides the ability to convert basic C++ 'cin' behavior.
//----------------------------------------------------------------------------------------
final class SimulateCin
{
private static boolean goodlastread = false;
static boolean lastReadWasGood()
{
return goodlastread;
}
static String readToWhiteSpace(boolean skipleadingwhitespace)
{
String input = "";
char nextchar;
if (skipleadingwhitespace)
{
while (Character.isWhitespace(nextchar = (char)System.in.read()))
{
}
input += nextchar;
}
while ( ! Character.isWhitespace(nextchar = (char)System.in.read()))
{
input += nextchar;
}
goodlastread = input.length() > 0;
return input;
}
}
{
static int Main()
{
menukar angka = new menukar();
angka.swap();
getch();
return 0;
}
}
public class menukar
{
public final void swap()
{
System.out.print("masukkan a :");
a = SimulateCin.readToWhiteSpace(true);
System.out.print("masukkan b :");
b = SimulateCin.readToWhiteSpace(true);
System.out.print("a=");
System.out.print(a);
System.out.print(",b=");
System.out.print(b);
System.out.print("\n");
System.out.print("b=");
System.out.print(b);
System.out.print(",a=");
System.out.print(a);
System.out.print("\n");
}
private int a;
private int b;
}
//----------------------------------------------------------------------------------------
// Copyright © 2006 - 2009 Tangible Software Solutions Inc.
//
// This class provides the ability to convert basic C++ 'cin' behavior.
//----------------------------------------------------------------------------------------
final class SimulateCin
{
private static boolean goodlastread = false;
static boolean lastReadWasGood()
{
return goodlastread;
}
static String readToWhiteSpace(boolean skipleadingwhitespace)
{
String input = "";
char nextchar;
if (skipleadingwhitespace)
{
while (Character.isWhitespace(nextchar = (char)System.in.read()))
{
}
input += nextchar;
}
while ( ! Character.isWhitespace(nextchar = (char)System.in.read()))
{
input += nextchar;
}
goodlastread = input.length() > 0;
return input;
}
}
Tidak ada komentar:
Posting Komentar