# (Solved Homework): CPS 180-Programming Assignment #5 Assigned: 05/31/17 Due: 06/07/17 Points: 40 Purpose: Use math functions,

Please do this lab to me. Please don’t give me something you have already gave to someone else.

CPS 180-Programming Assignment #5 Assigned: 05/31/17 Due: 06/07/17 Points: 40 Purpose: Use math functions, string manipulation and input/output to create an alternative to Twitter called Chipper. Requirements: 1. Ask the user for 3 messages to send using the following characteristics: a. Generate a random number to ask the user for a of chars for the message. The random number should be between l and 50. Use Math random to generate 3 numbers: randi, rand2, rand3 b. Have the user type the strings into 3 separate variables c. Find the length of the string and report if the string is too long, then truncate it and reassign it to the string 2. String variables: Keep track of all three messages in msgl, msg2, msg3 strings. Also combine (concatenate) all 3 messages into 1 string called msgAll 3. int variables: Keep track of the lengths of all three messages (after truncating) in msglLength, msg2Length, msg3Length 4. Counters a. Count and report the total of characters in msgAll. b. Count and report the number of vowels in msgAll (this will require a loop). c. Count and report the number of spaces in msgAll (this will require a loop). 5. Display msgAll backwards (this will require a loop). 6. Display msgAll Vertically (one char per line). Sample output (user input in bold): Note: The output is incomplete, just use as a reference. Message #1: Enter a message with 18 chars or less:

import java.util.Scanner;

public class Chipper {

public static void main(String[] args) {

int range = (50 – 1) + 1; // 50 is max value 1 is min value

int rand1 = (int) (Math.random() * range) + 1;// 1.a)gives a random
// number between 1 and
// 50
int rand2 = (int) (Math.random() * range) + 1;
int rand3 = (int) (Math.random() * range) + 1;

String msg1 = null;// 1.b) all strings in three input variables
String msg2 = null;
String msg3 = null;
Scanner in = new Scanner(System.in);
System.out.println(“Enter a message with ” + rand1 + ” character or less”);
msg1 = in.nextLine();
if (msg1.length() > rand1) {
System.out.println(“Oops! youe message is more than ” + rand1 + ” characters! it has been truncated to:”);
msg1 = msg1.substring(0, rand1);// 1.c) truncate string if
// length is more than random
// variable
System.out.println(msg1);
}
System.out.println(“Enter a message with ” + rand2 + ” character or less”);
msg2 = in.nextLine();
if (msg2.length() > rand2) {
System.out.println(“Oops! youe message is more than ” + rand2 + ” characters! it has been truncated to:”);
msg2 = msg2.substring(0, rand2);
System.out.println(msg2);
}
System.out.println(“Enter a message with ” + rand3 + ” character or less”);
msg3 = in.nextLine();
if (msg3.length() > rand3) {
System.out.println(“Oops! youe message is more than ” + rand3 + ” characters! it has been truncated to:”);
msg3 = msg3.substring(0, rand3);
System.out.println(msg3);
}
System.out.println(“Here is message1: ” + msg1);
System.out.println(“Here is message2: ” + msg2);
System.out.println(“Here is message3: ” + msg3);

String msgAll = msg1.concat(msg2).concat(msg3);// 2.Concatenate all
// string in one
System.out.println(“Here are your three messages combined: “);
System.out.println(msgAll);
System.out.println(“Here are your messages in all uppercase: “);
System.out.println(msgAll.toUpperCase());
System.out.println(“Here are your messages in all lowercase: “);
System.out.println(msgAll.toLowerCase());
int msg1Length = msg1.length();// 3.keeps the track of lengths of all
// three messages
int msg2Length = msg2.length();
int msg3Length = msg3.length();

// 4. a) count the total no of characters in string b) vowel count
// c)space count
int charCount = 0;
int spaceCount = 0;

int vowelCount = 0;
char temp;

for (int i = 0; i < msgAll.length(); i++) {
temp = msgAll.charAt(i);

if (temp != ‘ ‘)
charCount++;// counts character in string
if (temp == ‘ ‘)
spaceCount++;// count space in string
if ((temp == ‘a’) || (temp == ‘e’) || (temp == ‘i’) || (temp == ‘o’) || (temp == ‘u’))
vowelCount++;// counts vowels in string
}
System.out.println(“The count of character in all your messages: ” + charCount);
System.out.println(“The numbers of vowels in all your messages: ” + vowelCount);
System.out.println(“The number of spaces in all your messages: ” + spaceCount);
String backwardString = “”;
for (int i = msgAll.length() – 1; i >= 0; i–) {
backwardString = backwardString + msgAll.charAt(i);// 5. backward
// the string
// msgAll
}
System.out.println(“Here is your message backwards: ” + backwardString);
System.out.println(“Here is your message vertical: “);
for (int i = 0; i < msgAll.length(); i++) {
System.out.println(msgAll.toUpperCase().charAt(i));
}
}

}

output:

Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.