Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package mathtraning;
  2. import java.util.Scanner;
  3. /**
  4. *
  5. * @author Roy
  6. */
  7. public class Mathtraning {
  8. public static void main(String[] args) {
  9. Scanner in = new Scanner(System.in);
  10. System.out.println("Enter a function: mx + n");
  11. String function = in.next();
  12. char x = 'x';
  13. String d = "";
  14. for(int i=0;i<function.length();i++){
  15. if(function.charAt(i)==x){
  16. char num = function.charAt(i-1);
  17. d = d + num;
  18. }
  19.  
  20. System.out.println(d);
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement