(JAVA PLS)

Your job in this assignment is to write a program that takes a message as a string and reduces the number of characters it uses in two different set ways. The first thing your program will do is ask the user to type a message which will be stored as a String. The String entered should be immediately converted to lowercase as this will make processing much easier. You will then apply two different algorithms to shorten the data contained within the String.

Algorithm 1

This algorithm creates a string from the message in which every vowel (a, e, i, o, and u) is removed unless the vowel is at the very start of a word (i.e., it is preceded by a space or is the first letter of the message). Every repeated non-vowel character is also removed from the new string (i.e., if a character appears several times in a row it should only appear once at that location). So for example the string "I will arrive in Mississippi really soon" becomes "i wl arv in mssp rly sn".

After applying this algorithm, your program should output the shortened message, the number of vowels removed, the number of repeated non-vowel characters removed, and how much shorter the shortened message is than the original message. The exact format in which the program should print this information is shown in the sample runs.

Algorithm 2

This algorithm creates a string by taking each unique character in the message in the order they first appear and putting that letter and the number of times it appears in the original message into the shortened string. Your algorithm should ignore any spaces in the message, and any characters which it has already put into the shortened string. For example, the string "I will arrive in Mississippi really soon" becomes "8i1w4l2a3r1v2e2n1m5s2p1y2o".

After applying this algorithm, your program should output the shortened message, the number of different characters appearing, and how much shorter the shortened message is than the original message. The exact format in which the program should print this information is shown in the sample runs.

Sample Run 1
Type the message to be shortened
This message could be a little shorter

Algorithm 1
Vowels removed: 11
Repeats removed: 2
Algorithm 1 message: ths msg cld b a ltl shrtr
Algorithm 1 characters saved: 13

Algorithm 2
Unique characters found: 15
Algorithm 2 message: 4t2h2i4s1m5e2a1g1c2o1u3l1d1b2r
Algorithm 2 characters saved: 8
Sample Run 2
Type the message to be shortened
I will arrive in Mississippi really soon

Algorithm 1
Vowels removed: 11
Repeats removed: 6
Algorithm 1 message: i wl arv in mssp rly sn
Algorithm 1 characters saved: 17

Algorithm 2
Unique characters found: 13
Algorithm 2 message: 8i1w4l2a3r1v2e2n1m5s2p1y2o
Algorithm 2 characters saved: 14

Answers

Answer 1

import java.util.Scanner;

public class JavaApplication54 {

   public static int appearance(String word, char letter){

       int count = 0;

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

           if (word.charAt(i) == letter){

               count++;

           }

       }

       return count;

   }

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Type the message to be shortened");

       String message = scan.nextLine();

       message = message.toLowerCase();

       int volCount = 0, repCount = 0, num = 0;

       char prevC = ' ';

       String vowels = "aeiou";

       String newMessage = "";

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

           char c = message.charAt(i);

           

           if (vowels.indexOf(c) != -1 && prevC == ' '){

               newMessage += c;

           }

           else if (vowels.indexOf(c) == -1 && prevC != c){

               newMessage += c;

           }

           else if (vowels.indexOf(c) != -1){

               volCount ++;

           }

           else{

               repCount++;

           }

            prevC = c;

       }

       System.out.println("Algorithm 1");

       System.out.println("Vowels removed: "+volCount);

       System.out.println("Repeats removed: "+repCount);

       System.out.println("Algorithm 1 message: "+newMessage);

       System.out.println("Algorithm 1 characters saved: "+(message.length() - newMessage.length()));

       

       String uniqueMessage = "";

       

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

           char w = message.charAt(i);

           if (uniqueMessage.indexOf(w)== -1 && w!=' '){

               uniqueMessage += appearance(message,w)+""+w;

               num++;

           }

       }

       System.out.println("Algorithm 2");

       System.out.println("Unique characters found: "+num);

       System.out.println("Algorithm 2 message: "+uniqueMessage);

       System.out.println("Algorithm 2 characters saved: "+(message.length() - uniqueMessage.length()));

   }

   

}

I hope this helps!


Related Questions

Day 1 of seeing if anyone will buy me a psn gift card (if u do u get brainliest and thanks + alot of points

Answers

today is not the day keep trying

Simon takes apart a computer and looks at the thin green boards inside. What are these?
A. binary boards
B. database boards
C. input devices
D. circuit boards

Answers

Answer:

These green boards are circuit boards, these are green in color coz they protect the inner copper lining.

50 POINTS
in Java
A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.

In this program, ask the user to input some text and print out whether or not that text is a palindrome.

Create the Boolean method isPalindrome which determines if a String is a palindrome, which means it is the same forwards and backwards. It should return a boolean of whether or not it was a palindrome.

Create the method reverse which reverses a String and returns a new reversed String to be checked by isPalindrome.

Both methods should have the signature shown in the starter code.

Sample output:

Type in your text:
madam
Your word is a palindrome!
OR

Type in your text:
hello
Not a palindrome :(

Answers

import java.util.Scanner;

public class JavaApplication52 {

   public static String reverse(String word){

       String newWord = "";

       for (int i = (word.length()-1); i >= 0; i--){

           newWord += word.charAt(i);

       }

       return newWord;

   }

   public static boolean isPalindrome(String word){

       if (word.equals(reverse(word))){

           return true;

       }

       else{

           return false;

       }

   }

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Type in your text:");

       String text = scan.nextLine();

       if (isPalindrome(text) == true){

           System.out.println("Your word is a palindrome!");

       }

       else{

           System.out.println("Not a palindrome :(");

       }

   }

   

}

I hope this works!

What are the two reasons we analyze algorithms?

Predict performance

Make decisions about what algorithm to use

Sorting Data

Ease of coding

Answers

Answer:

Predict performance  

 Make decisions about what algorithm to use

Explanation:

The two reasons we analyze algorithms are:

A. Predict performance B. Make decisions about what algorithm to use

An algorithm refers to those steps and processes which a person undertakes in order to solve a problem.

As a result of this, it is important that we make analysis of an algorithm so that we can make predictions which would help us take vital decisions about the type of algorithm to use.

Therefore, the correct answers are options A and B

Read more here:

https://brainly.com/question/17648604

Lloyd has created a validation script for a data entry form. What property should he use to test for a selected radio button?
A. checked
B. selected
C. ticked
D. clicked

Answers

Answer:

the answers A

Explanation:

i took the test and only did that question to make sure

Consider the following code:
val = 0
while (val < 10):
val = val - 1
print (val)
What is the error?

Answers

Answer:

The code will get stuck in an infinite loop.

Explanation:

Since val is decreasing by 1 each time it meets the criteria of being smaller than 10, your code will get stuck in an infinite loop since val will always be smaller than 10.

Hope this helps :)

Select the correct answer.
What is the coding process commonly also called?
A. testing
B. development
C. debugging
D. refining

Answers

Answer:

B.

Explanation:

Answer:

development

is the correct answer

The___ of a variable is determined by which parts of a program can view and change its value

Answers

The missing word is scope. Wherever a variable is declared, is its scope. A variable can be manipulated or called on only in its scope.

The scope of a variable is determined by which parts of a program can view and change its value. The correct option is C.

What is a variable?

A variable in programming is a value that can change depending on the conditions or information passed to the program.

A program is typically made up of instructions that tell the computer what to do and data that the program uses while running.

Variables are used to store data that can be accessed and manipulated by a computer program. They also allow us to label data with descriptive names, making our programs easier to understand for both the reader and ourselves.

In layman's terms, a variable's scope is its lifetime in the program. This means that the scope of a variable is the entire program's block of code where the variable is declared, used, and can be modified.

Thus, the correct option is C.

For more details regarding variable, visit:

https://brainly.com/question/17344045

#SPJ2

Your question seems incomplete, the missing options are:

influence

magnitude

scope

range

make an internet research on different hazards and risk​

Answers

Answer:

As internet use is extending to younger children, there is an increasing need for research focus on the risks young users are experiencing, as well as the opportunities, and how they should cope. With expert contributions from diverse disciplines and a uniquely cross-national breadth, this timely book examines the prospect of enhanced opportunities for learning, creativity and communication set against the fear of cyberbullying, p*rnography and invaded privacy by both strangers and peers. Based on an impressive in-depth survey of 25,000 children carried out by the EU Kids Online network, it offers wholly new findings that extend previous research and counter both the optimistic and the pessimistic hype. It argues that, in the main, children are gaining the digital skills, coping strategies and social support they need to navigate this fast-changing terrain. But it also identifies the struggles they encounter, pinpointing those for whom harm can follow from risky online encounters. Each chapter presents new findings and analyses to inform both researchers and students in the social sciences and policy makers in government, industry or child welfare who are working to enhance children's digital experiences.

Hazard is something with the opportunities to be harmful and the risk refers to the extent to which harm is likely to occur.

Many incidents are completely preventable, as well as the approach to doing just that would be to eliminate all potential dangers. Some objects are dangerous by nature, although some may be dangerous if handled wrongly as well as irresponsibly.

There are two kinds of hazards, such as:

Acute Hazard Chronic Hazard

The risk seems to be a fusion of various factors:

The actual likelihood that somehow a hazard might inflict damage.The severity of just that impairment.

Learn more about hazards here:

https://brainly.com/question/13084967

How do you insert text into a presentation?

by clicking in a placeholder and entering text
by clicking in the task pane and entering text
by drawing a text box, clicking in it, and entering text
by selecting Text from the Insert menu

Answers

Answer:

Hello your answer is:

clicking in a placeholder and entering text

drawing a text box, clicking in it, and entering text

Explanation:

I did the assignment on edge 2021-2022

Answer: clicking in a placeholder and entering text, and

drawing a text box, clicking in it, and entering text

(it's a fill in the blank)
____ provide the means for other professions to perform their jobs more efficiently and effectively.

Answers

Please provide the means for other professions to perform their jobs more efficiently and effectively.

Answer:

programmers

Explanation:

das what it js

Zachary is a member of Future Business Leaders of America at his school and is competing in the Impromptu Speaking competition. Before he presents to the judges, he is given the topic, a note card, and five minutes to prepare his speech. What impromptu speaking tip should Zachary follow? (5 points)
a. Sketch a picture to show the judges along with his speech.
b. Use as much memorized material as he can.
c. Start off the speech with a personal story.
d. Talk very fast during the speech so he sounds like an expert.

Answers

Answer:

c start off with a story

Explanation:

I just took the test

Answer:

c

Explanation:

I'll give brainlyist
Identify data types
13.5
-6
“18 Mingle Lane”
False
-20.4
“Bonjour”
12345

Answers

Answer:

1. Float

2. Integer

3. String

4. Boolean

5. Float

6. String

7. Integer

Explanation:

To identify data types, we need to understand the following concepts.

Data types are categorised into 2.

1. Numeric data types

2. Non numeric data types

The numeric data types are represented by numbers and is subdivided into 2.

i. Integer: Numbers without decimals (could be positive or negative)

ii. Float or Real: Numbers with decimals (could also be positive or negative)

Going by the above illustration,

13.5 and -20.4 are float data types

-6 and 12345 are integer

2. Non numeric data types: These are data that are different from numbers or digits. They could be images, string & character, boolean, dates, etc.

I'll limit my explanation to the scope of this assignment.

String are texts and are denoted by open and close quotes ("...") i.e. data that are present with quotes are strings

Boolean are data with true or false values

So, by this explanation:

"18 Mingle Lane" and "Bonjour" are strings variables

And

False is boolean

Answer:

Float, Integer, String, Boolean, Float, String, Integer.  

Explanation:

1.Anong uri ng application software ang iyong ginamit upang makapagtutuos ka ng datos?

2.Mahalaga ba na matutunan mo ang ganitong kasanayan sa pagtutuos o pagkalkyula ng mga datos gamit ang spreadsheet software sa computer?

Answers

Answer:

The answer is "Microsoft Excel"

Explanation:

Please find the complete and correct question in the attached file.

It will use Microsoft Excel to calculate formulas may be put throughout every cell. Excel works for use of the readily accessible or available on-line resources.  

It can be linked to multiple files, servers, and information sources. It can also create a factory reset to allow Excel to process a data box folder, that's why it's important to learn to quantify of it's skill.

A new computer virus attacks a folder consisting of 200 files. Each file gets damaged with probability 0.2 independently of other files. What is the probability that fewer than 50 files will get damaged? g

Answers

Answer:

0.95345

Explanation:

Given that :

Number of files (n) = 200

Probability of getting damaged (p) = 0.2

q = 1 - p = 1 - 0.2 = 0.8

using normal approximation:

Mean (m) = np = 200 * 0.2 = 40

Standard deviation (s) = √n*p*q= √(200 * 0.2 * 0.8) = 5.6568542

P(X < 50)

X = 50 - 0.5 = 49.5

Find the standardized score :

Z = (x - m) / s

Z = (49.5 - 40) / 5.6568542

Z = 9.5 / 5.6568542

Zscore = 1.6793786

P(Z < 1.6793) = 0.95345 ( using Z probability calculator)

35 POINTS
In Java PLS
This program is the beginning of an automated order machine. You are programming the piece that gets the number of the order from the label sent to you by the ordering machine.

The ordering machine is simulated with user input. It sends a full label, such as “3. Veggie Burger”.



Fill in the missing code
Your task is to get the number out of the string. To do this, you need to isolate the number by using substring. Then use Integer.valueOf, a static method of Integer that takes a String and returns the integer value contained in the String.

The final program should look something like this

1. Hamburger
2. Cheeseburger
3. Veggie Burger
4. Nachos
5. Hot Dog

Enter label:
5. Hot Dog
Customer ordered number 5

This is the code given:
import java.util.Scanner;

public class PickupWindow
{
public static void main(String[] args)
{
// Create scanner object
Scanner input = new Scanner(System.in);

// Display menu
String menu = "1. Hamburger\n2. Cheeseburger\n3. Veggie Burger\n4. Nachos\n5. Hot Dog\n";

System.out.println(menu);

// Get customer order
System.out.println("Enter label: ");
String customerOrder = input.nextLine();

// Use substring to get the first character (the number)
String combo =

// Create an Integer object by using the static
// method Integer.valueOf(someString)
// to turn the string into an Integer

Integer comboNumber =

// Print out what the customer ordered
System.out.println("Customer ordered number "


}
}

Answers

Answer:

Complete the program as follows:

1. Replace

String combo =

with

String combo = customerOrder.substring(0);

2. Replace

Integer comboNumber =

with

Integer comboNumber = Integer.parseInt(combo);

Explanation:

Required

Fill in the missing codes

From the code given, there are only two gaps to be filled and they are:

1. String combo =

2. Integer comboNumber =

1. String combo =

The first is to get the first index of customerOrder using substring.

The syntax of this is:

variable.substring(0);

In this case, the syntax will be replaced with:

String combo = customerOrder.substring(0);

Where customerOrder represents the string variables

2. Integer comboNumber =

This is to convert combo from string to integer using parseInt

This is done as follows:

Integer comboNumber = Integer.parseInt(combo);

See attachment for complete code

why was the tesla model s help change the was we see EV

Answers

Answer:

It showed people that electric cars are advancing, and soon will be the norm.

Lots of people thought that EV cars would never be able to last as long as gas powered cars. However, with technology importing, Tesla cars are getting closer and closer to being able to provide the same amount of millage as the gas powered cars.

an organization wants to use its computer to make video calls with suppliers overseasename two input and two output device that the organisation must have for this to happen and briefly explain the popruse of each device

Answers

Answer:

an organization wants to use its computer to make video calls with suppliers overseasename two input and two output device that the organisation must have for this to happen and briefly explain the popruse of each device

A swimming pool has a length of 28 feet, a width of 17 feet, and a depth of 6 feet. How much water can the swimming pool hold?

Answers

2140 Gallons/LBFOR EACH AND JOE BIDEN WONNN YAAAA

Which of the following audio file formats will provide the best audio streaming on the Internet?

Answers

Answer:

MP3

Explanation:

MP3 and . MP4 are the best audio file formats for use on the Web. All modern browsers support this format, including IE9. Other formats that are supported by most browsers include OGG, WebM, AAC, and WAV

Answer:

MP3

Explanation:

Edge 2021

How can you tell if an email has an attachment? How do you download it? What folder does it download to?

Answers

Well the folder you get to pick on which one and it’ll basically have a this

why is this statement false: "when choosing the color of your font and your template background color, it is best to make them close in tone and hue"?

Answers

Answer:

A

Explanation:

Just a very strong guess

Which of the following is an open-source web browser?
O Firefox
O Internet Explorer
O Opera
O Telnet

Answers

Answer:

Firefox

Explanation:

Not much to explain.

Firefox is the only open-sourced web browser here.

JAVA
Write a program into which we could enter Lily's Longitude and Latitude data. Each time a new longitude and latitude is entered it should ask if you
want to continue - the program should continue to ask for input if the user enters 1, and stop when the user enters 0. If an invalid pair of coordinates
entered by the user (i.e. with latitude not between - 90 and 90 inclusive or longitude not between -180 and 180 inclusive) then the program should
print "Incorrect Latitude or Longitude".
Once the user has finished inputting data, the program should display the farthest distance traveled by Lily in each direction (you may assume the user
has entered at least one valid longitude/latitude pair). However any invalid pairs of coordinates should be ignored when calculating these values - this
includes ignoring a valid latitude if it is entered with an invalid longitude and vice-versa.
The farthest points are given by:
• Farthest North - maximum latitude
• Farthest South- minimum latitude
• Farthest East - maximum longitude
• Farthest West - minimum longitude
Please note - you are not expected to enter all of Lily's data into your program: you can simply make up some sample data points if you wish.
the sample runs are in the picture.

Answers

import java.util.Scanner;

public class JavaApplication59 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       double north = -180, south = 180, east = -90, west = 90;

       while (true){

           System.out.println("Please enter the longitude:");

           double lon = scan.nextDouble();

           System.out.println("Please enter the latitude:");

           double lat = scan.nextDouble();  

           if (lon > 90 || lon < -90 || lat >180 || lat < -180){

               System.out.println("Incorrect Latitude or Longitude");

           }

           else{

               if (lat > north){

                   north = lat;

               }

               if (lat < south){

                   south = lat;

               }

               if (lon > east){

                   east = lon;

               }

               if (lon < west){

                   west = lon;

               }

           }

           System.out.println("Would you like to enter another location (1 for yes, 0 for no)?");

           int choice = scan.nextInt();

           if (choice == 0){

               break;

           }

       }

       System.out.println("Farthest North: "+north);

       System.out.println("Farthest South: "+south);

       System.out.println("Farthest East: "+east);

       System.out.println("Farthest west: "+west);

   }

   

}

I hope this helps!

Write a section of code that asks the user for their last name and then will create A new string produced by randomly splitting their name into two parts and reversing their order.
Example: "computer" may produce the result "utter comp".

Answers

import random

name = input("Enter your last name: ")

w = random.randint(0,len(name)-1)

txt = name[0:w]

txt1 = name[w:]

print(txt1+" "+txt)

I hope this helps!

__ is a process of adding details to a model to make it less abstract.
• abstraction
• decomposition
• pattern recognition
• refinement

Answers

Answer:refinement

Explanation:

Answer:

refinement

Explanation: just checked

Security breaches are easier to address with which payment form?

Answers

Answer:

Cause #1: Old, Unpatched Security Vulnerabilities. ...

Cause #2: Human Error. ...

Cause #3: Malware. ...

Cause #4: Insider Misuse. ...

Cause #5: Physical Theft of a Data-Carrying Device

Explanation:

Answer:

i think the second one

Explanation:

Plz answer fast! Mary needs to choose the ________ menu in order to place the text in a desired fashion around the image.

Answers

Full features menu is needed

Please help answer now! First correct answer get branliest! Place the directions in order from first to last to explain how to hide the ribbon from the top of your Excel worksheet.

Move the cursor to the top-right corner

Select the auto-hide ribbon

Click on the up arrow

Answers

Answer:

just do bodldld

Explanation:

Answer:

Move the cursor to the top-right corner

Click on the up arrow

Select the auto-hide ribbon

Explanation:

You would like to narrow your search on this topic.
a) You want to look for information on this topic's history, but you don't want to include any information that pre-dates 1975. What Boolean operator would you use?

Answers

Answer: AND

Explanation: which combines words together to narrow a search

The Boolean operator would you use is AND. Check below what the operator is about.

What is the Boolean Operators about?

This is known to be some simple words such as (AND, OR, NOT or AND NOT.

They are often used in the case of making a search, an it is one that brings about a productive results and as such, the use of AND in a search can help to narrow your results to the  topic's history.

Learn more about Boolean operator from

https://brainly.com/question/1675220

#SPJ2

Other Questions
Which of the following is NOT included in the Townshend Taxes?Leadfirewoodglasspaperpainttea Draw the graph of y=2x+3 on the grid A wet electrode can cause arc blow ? Elena bought 8 tokens for $4.40. At this rate: 1)How many tokens could she buy with $6.05? 2) How much do 19 tokens cost? What is the similirities between meteors and meteoried $3.98 divided by 100 In a group of 10 boys each boy had 2hats how many hats did they have Find X if m/angle UVY=84 degrees. unscramble dki-----------------------------------------------------------------------........... Rebecca is distributing fidget spinners as part of her campaign for school president. she has 500 fridge my spinners to distribute in packs of 25 per teacher. write a function modeling this situation. define all unknown variables Solve for x: 7x + 15 = 38A: 23/7B: 53/7C: 23D: 53 Graph the line y=3/2x-1 The information below describes the position of a city manager.In the city-manager form of municipal government, an elected city council hires a citymanager. The city manager is an expert in public administration who runs city services.What was a DISADVANTAGE of this new form of city government?A. City government became more efficient than before.B. The city manager was not directly responsible to the electorate.C. Experts with special training in public administration ran the city.D. The influence of political machines on city government was reduced. -19 + __ = -48 what is the unknown addend plz what does denotation mean? Lifetime Health Chapter 7 section 4 healthful diet what is the equation a line passes through the points p(2,4) q(-1,3) the balcony scene from Romeo and Juliet. In a well constructed paragraph, compare and contrast the meaning that is portrayed in each. Find coordinates of the image of the point A(3,9) for a dilation with the scale factor of 2/3 pls write the steps u did