所以在我的程序中,我需要知道该程序是否在Windows 7或10中运行。是否有任何方法或模块可以做到这一点?
答案 0 :(得分:0)
package loopy;
import java.io.*;
public class loopy {
public static void main (String[] args) {
// TODO: Use a loop to print every upper case letter
for (int i = 65; i < 91; i++) {
System.out.println((char)i);
}
// TODO: Get input from user. Print the same input back but with cases swapped.
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
String input = in.readLine(); // get the actual input
toggleStringCase(input); // MOVE IT HERE
// The try/catch below are commented out since you can combine it to the try/catch above
// START
//} catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
//}
//try {
// END
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// toggleStringCase(input); // was moved inside try-catch
}
// TODO: Implement this function to return the opposite case of the letter given. DO NOT USE any built in functions.
// How to handle the case where the char given is not a letter?
private static char toggleCase(char c) {
return c;
}
// TODO: Implement this function to toggle the case each char in a string. Use toggleCase() to help you.
private static String toggleStringCase(String str) {
return str;
}
}