Welcome to Westonci.ca, your go-to destination for finding answers to all your questions. Join our expert community today! Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.

Write a Java program that takes as input a paragraph as a String and identifies if any of the words in the paragraph is a $1.00 word. The value of each word is calculated by adding up the value of each one of its characters. Each letter in the alphabet is worth its position in pennies i.e. a

Sagot :

Answer:

In Java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Enter paragraph: ");

 String para = input.nextLine();

 String[] para_words = para.split("\\s+");

 for (int i = 0; i < para_words.length; i++) {

     para_words[i] = para_words[i].replaceAll("[^\\w]", "");

     char[] eachword  = para_words[i].toCharArray();

     int penny = 0;

     for(char c : eachword){

         int value = (int)c;

         if(value<=122 && value>=97){   penny+=value-96;     }

         else if(value<=90 & value>=65){  penny+=value-64;  }

     }

     if(penny == 100){

         System.out.println(para_words[i]);

     }

       penny = 0;

}

}

}

Explanation:

Due to the length of the explanation, I've added the explanation as an attachment

View image MrRoyal
We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.