Question

/* Lab 7, Part E: Created by Celine Latulipe public class Lab7Parte { public static void main(String [] args) // TODO: put yo

/* Lab 7, Part F: Created by Celine Latulipe public class Lab 7PartF { public static void main(String [] args) { // TODO: put

• Download Lab7PartF.java and save it to the usual directory. This program is an empty shell that does nothing. Inside the ma

Help with program

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program 1:

import java.lang.Math;

public class Lab7PartE{
   public static void main(String[] args) {
       int rand_num=(int)(Math.random()*21);   //generating the random number in the range 0-20
       for(int i=1;i<=rand_num;i++){   //running the loop rand_num times
           System.out.print("*");   //printing the asterisk
       }
       System.out.println();   //printing newline after asterisks

       if(rand_num%2==0){   //test for even
           System.out.println(rand_num+" asterisks, which is an even number.");
       }
       else{   //test for odd
           System.out.println(rand_num+" asterisks, which is an odd number.");
       }
   }
}

Program 2:

public class Lab7PartF{
   public static void main(String[] args) {
       int ascii=97;   //the ascii value of a
       char letter;   //tostore the character at ascii value
       for(;ascii<=122;ascii++){   //running the loop uptill ascii value of z

           letter=(char)ascii;   //type-casting int to char type

           if(letter=='a'||letter=='e'||letter=='i'||letter=='o'||letter=='u'){   //checking if letter is a vowel
               //subtracting 32 from letter and casting to character to get the Uppercase letter
               System.out.print((char)(letter-32));  
           }
           else{   //if not vowel then print letter unchanged
               System.out.print(letter);
           }
       }
       System.out.println();   //printing newline after asterisks

   }
}

Please give a like

Add a comment
Know the answer?
Add Answer to:
Help with program /* Lab 7, Part E: Created by Celine Latulipe public class Lab7Parte {...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA Code: Complete the program that reads from a text file and counts the occurrence of...

    JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...

  • Hi I really need help with the methods for this lab for a computer science class....

    Hi I really need help with the methods for this lab for a computer science class. Thanks Main (WordTester - the application) is complete and only requires uncommenting to test the Word and Words classes as they are completed. The needed imports, class headings, method headings, and block comments are provided for the remaining classes. Javadocs are also provided for the Word and Words classes. Word The Word class represents a single word. It is immutable. You have been provided...

  • I need eclipse code for : Write a program that analyzes text written in the console...

    I need eclipse code for : Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

  • Question 0: package hw3; public class Question0 { /* * TODO: Complete the method isSorted that...

    Question 0: package hw3; public class Question0 { /* * TODO: Complete the method isSorted that * takes in as input an array of String * and returns back a boolean value whether it * is sorted in Lexicographical order or not. * You can read up more on this here: * https://en.wikipedia.org/wiki/Lexicographical_order */ public static boolean isSorted(String[] array) { } /* * Do not write any code inside the main method and expect it to get marked. * Any...

  • 6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you...

    6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...

  • JAVA PROBLEM! PLEASE DO IT ASAP!! REALLY URGENT! PLEASE DO NOT POST INCOMPLETE OR INCORRECT CODE...

    JAVA PROBLEM! PLEASE DO IT ASAP!! REALLY URGENT! PLEASE DO NOT POST INCOMPLETE OR INCORRECT CODE Below is the program -- fill the code as per the instructions commented: //---------------------------------------------------------------------------------------------------------------------------------------------------------------// /* The idea of this HW is as follows : A password must meet special requirements, for instance , it has to be of specific length, contains at least 2 capital letters , 2 lowercase letters, 2 symbols and 2 digits. A customer is hiring you to create a class...

  • LAB: Ticketing service (Queue)

    LAB: Ticketing service (Queue)Given main(), complete the program to add people to a queue. The program should read in a list of people's names including "You" (ending with -1), adding each person to the peopleInQueue queue. Then, remove each person from the queue until "You" is at the head of the queue. Include print statements as shown in the example below.Ex. If the input is:Zadie Smith Tom Sawyer You Louisa Alcott -1the output is:Welcome to the ticketing service...  You are number 3 in the queue. Zadie Smith has purchased a ticket. You are now number 2 Tom Sawyer has purchased a ticket. You are now number 1 You can now purchase your ticket!TicketingService.javaimport java.util.Scanner; import java.util.LinkedList; import java.util.Queue; public class TicketingService {    public static void main (String[] args) {       Scanner scnr = new Scanner(System.in);...

  • Program Description: A Java program is to be created to produce Morse code. The Morse code...

    Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Given main(), complete the program to add people to a queue

    4.14 LAB: Ticketing service (Queue)Given main(), complete the program to add people to a queue. The program should read in a list of people's names including "You" (ending with -1), adding each person to thepeopleInQueue queue. Then, remove each person from the queue until "You" is at the head of the queue. Include print statements as shown in the example below.Ex. If the input isZadie Smith Tom Sawyer You Louisa Alcottthe output isWelcome to the ticketing service...  You are number 3 in the queue. Zadie Smith has purchased a ticket. You are now number 2 Tom Sawyer has purchased a ticket. You are now number 1 You can now purchase your ticket!Code that I have been...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT