Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- new Main().run();
- }
- public void run() {
- final int FINE_AMOUNT = 3;
- String userInput = ask("What sentence shall I analyze?");
- int numCharacter = analyzer(userInput);
- Scanner keyboard = new Scanner(System.in);
- }
- private String ask (String question) {
- System.out.print(question);
- String input = keyboard.nextLine();
- String finalInput = input.toUpperCase();
- return finalInput;
- }
- private int analyzer(String userInput) {
- int letterAnalyzer = userInput.indexOf("S");
- if( letterAnalyzer >= 0 ) {
- int characters = userInput.length();
- return characters;
- } else {
- }
- private void calculator(int numCharacter) {
- int totalFine = numCharacter;
- if(totalFine <= 12) {
- int fine;
- int fine = 14;
- System.out.print("That sentence contains a bad word.The fine: 14 zorkmids.");
- } else if(totalFine > 12){
- int fine;
- int fine = totalFine * FINE_AMOUNT;
- System.out.print("That sentence contains a bad word. The fine: " + fine$ +"zorkmids.");
- } else {
- System.out.print("No bad words found.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment