Question

In: Computer Science

One of your friends has an awful writing style: he almost never starts a message with...

  1. One of your friends has an awful writing style: he almost never starts a message with a capital letter, but adds uppercase letters in random places throughout the message. It makes chatting with him very difficult for you, so you decided to write a plugin that will change each message received from your friend into a more readable form.

Implement a function that will change the very first symbol of the given message to uppercase, and make all the other letters lowercase.

2. Implement a function that will compute the area of a triangle.

Solutions

Expert Solution

Ques 1)

package string.manipulation;

import java.util.Scanner;

public class StringManipulation {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); //object to take input
        
        System.out.println("Enter message");
        String str = sc.nextLine(); // taking input
       
        String output = str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); // changing message to proper format
        System.out.println("Corrected Message: " + output); // printing result
    }
}

Output:-

Ques 2)

package areaoftriangle;

import java.util.Scanner;

public class AreaOfTriangle {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); // object to take input
        
        System.out.println("Enter height of triangle");
        int h = sc.nextInt(); //height of triangle
        
        System.out.println("Enter base of triangle");
        int b = sc.nextInt(); // base of triangle
        
        //area of triangle = (h*b) / 2
        System.out.println("Area of Triangle: " + h*b/2);
    }
}

Output:-

In the first program predefined String function is used to convert each alphabet of string to lower and upper case.

Second program calculates the area of triangle on the basis of it's height and base.

Note:- Please comment down if you face any problem. :)


Related Solutions

a) One of your friends called you to say that a message suddenly appeared on his...
a) One of your friends called you to say that a message suddenly appeared on his screen that says his/her software licence has expired and he/she must immediately pay $2000 to have it renewed before control of the computer will be returned to him/her. Identify and discuss this malware. Being a student of networking/cyber- security, what recommendations would you give to your friend regarding the importance of information security and how to mitigate this kind of malware attack? b) You...
If one of the benefits of blogging is the personal, intimate style of writing, is it...
If one of the benefits of blogging is the personal, intimate style of writing, is it a good idea to limit your creativity by adhering to conventional rules of grammar, spelling, and mechanics? Why or why not? 200 word response please. Thanks in advance!
How could you improve your academic writing style?
How could you improve your academic writing style?
An accountant friend of yours tells you that he “almost never” does any tax research because...
An accountant friend of yours tells you that he “almost never” does any tax research because he believes that “research usually reveals that some tax planning idea has already been thought up and shot down.” Besides, he points out, most tax returns are never audited by the IRS. Can a tax adviser who is dedicated to reducing his client’s tax liability justify the effort to engage in tax research? Do professional ethics demand such efforts? Which approach would a client...
Your friend owns a business that offers customers credit on their purchases, but she/he has never...
Your friend owns a business that offers customers credit on their purchases, but she/he has never used any of the generally accepted allowance methods to calculate and record bad debt expense. For this discussion, prepare a recommendation for the business as follows: Review the generally accepted allowance methods and determine which one you believe is the best method. Prepare a summary of the method you selected that justifies why you believe it is the best method
One of your friends has recently married and has now confided in you that she is...
One of your friends has recently married and has now confided in you that she is pregnant. She knows you’re taking this class in lifespan development and asked for your input concerning what she can expect when giving birth, and she want your suggestions concerning her childbirth options. What would you tell her about the three stages of birth, complications she might expect, options about the use of drugs, and the childbirth strategies that are available to her
Imagine that one of your friends is pregnant. She is 22 years old and has a...
Imagine that one of your friends is pregnant. She is 22 years old and has a diet rich in dark and leafy vegetables, legumes and citrus fruits (all of which are good sources of folate). Her doctor recommends her to take a folic acid supplement, which is suggested for all pregnant woman. She approaches you with the two different supplements Nature Made, Folic Acid, 400 mcg per pill Nature's Blend, Folic Acid, 1000 mcg per pill Based on the RDAs...
One of your friends is preparing for a run in a marathon. She has heard about...
One of your friends is preparing for a run in a marathon. She has heard about eating a pasta dinner to glycogen load the evening prior to the marathon. Explain in biochemical terms what glycogen loading is and how it works? Please include hormonal controls, key enzymes and a discussion of both liver and muscle in the process.
A major revision task involves assessing the clarity of your message. A clear message is one...
A major revision task involves assessing the clarity of your message. A clear message is one that is easily understood. Describe three techniques that can improve the clarity of your writing. Include an example of each technique. (Learning Objective 2)
Your friend John has never learned Economics. He wants to know the differences between a change...
Your friend John has never learned Economics. He wants to know the differences between a change in the quantity demanded and a change in demand. He also wants to know the differences between a change in the quantity supplied and a change in supply. a) Explain to John the differences between a change in the quantity demanded and a change in demand. b) Explain to John the differences between a change in the quantity supplied and a change in supply.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT