Write code to take a String input from the user, then print the first and last letters of the string on one line. Sample run: Enter a string: surcharge se Hint - we saw in the lesson how to get the first letter of a string using the substring method. Think how you could use the .length() String method to find the index of the last character, and how you could use this index in the substring method to get the last character.

Answers

Answer 1
Answer:

//import the Scanner class to allow for user input

import java.util.Scanner;

//Begin class definition

public class FirstAndLast{

   //Begin the main method

    public static void main(String []args){

       

       

       //****create an object of the Scanner class.

       //Call the object 'input' to receive user's input

       //from the console.

       Scanner input = new Scanner(System.in);

       

       //****create a prompt to tell the user what to do.

       System.out.println("Enter the string");

       

       //****receive the user's input

       //And store it in a String variable called 'str'

       String str =  input.next();

       

       //****get and print the first character.

       //substring(0, 1) - means get all the characters starting

       //from the lower bound (index 0) up to, but not including the upper

       //bound(index 1).

       //That technically means the first character.

       System.out.print(str.substring(0,1));

       

       //****get and print the last character

       //1. str.length() will return the number of character in the string 'str'.

       //This is also the length of the string

       //2. substring(str.length() - 1) - means get all the characters starting

       // from index that is one less than the length of the string to the last

       // index (since an upper bound is not specified).

       // This technically means the last character.

       System.out.print(str.substring(str.length()-1));

       

       

       

    }  // end of main method

   

} //end of class definition

Explanation:

The code has been written in Java and it contains comments explaining important parts of the code. Kindly go through the comments.

The source code and a sample output have also been attached to this response.

To run this program, copy the code in the source code inside a Java IDE or editor and save it as FirstAndLast.java

Write Code To Take A String Input From The User, Then Print The First And Last Letters Of The String

Related Questions

Which of the following describes an iteration in a computer program?

Answers

Answer:

a set of instructions that can be run multiple times throughout a program

Explanation:

Question # 18
Dropdown
A(n)
is the tool that will help you the most when developing the content you will use in your presentation.

Answers

Your answer is outline.

An outline is the tool that will help you the most when developing the content you will use in your presentation.

What is presentation?

A presentation is a method of communicating information from a speaker to an audience.

Presentations are usually demonstrations, introductions, lectures, or speeches intended to inform, persuade, inspire, motivate, build goodwill, or introduce a new idea/product.

An outline is a list of the main topics and subtopics that you intend to cover in your presentation in a hierarchical order.

It can assist you in ensuring that your ideas flow logically and that no important points are overlooked.

A storyboard, on the other hand, is a visual representation of your presentation that shows the order of your slides, the images or videos you intend to use, and the text that will go with them.

Thus, the answer is outline.

For more details regarding presentation, visit:

https://brainly.com/question/938745

#SPJ7

What is the difference between autofocus and autocomplete

Answers

Answer:

https://www.c-sharpcorner.com/interview-question/explain-autofocus-and-autocomplete-attribute

found this on a website hope you find it useful !

The network performance is said to be biased when _________.

a) It performs well on train set but poorly on dev set
b) it performs poorly on train set
c) Both the options
d) None of the options

Answers

Answer:

the answer for the question is B

The network performance is said to be biased when it performs poorly on train set.

What is network performance?

A measurement regarding service or the state of quality of network received by the consumer is known as network performance. Operators can control the upper limit of a network performance.

When network operators or service providers put a cap and lower the speed of a network on a train set, it is said to be a biased network performance.

Hence, option B holds true regarding network performance.

Learn more about network performance here:

https://brainly.com/question/12968359

#SPJ2

write down the multiples of three from 474 to 483​

Answers

Answer:

474, 477, 480, 483

hope this helps

have a good day :)

Explanation:

what is mobile computing​

Answers

Explanation:

Mobile computing is human–computer interaction in which a computer is expected to be transported during normal usage, which allows for the transmission of data, voice, and video. Mobile computing involves mobile communication, mobile hardware, and mobile software. ... Hardware includes mobile devices or device components.

Question: what is mobile computing

Answer:

Mobile computing is human–computer interaction in which a computer is expected to be transported during normal usage, which allows for the transmission of data, voice, and video. Mobile computing involves mobile communication, mobile hardware, and mobile software. Communication issues include ad hoc networks and infrastructure networks as well as communication properties, protocols, data formats, and concrete technologies. Hardware includes mobile devices or device components. Mobile software deals with the characteristics and requirements of mobile applications.

Explanation:

Hope it helps

#CarryOnLearning

advantages of torsion in engineering​

Answers

Answer:

Ascertain product failure

Let L be the set of exactly those strings over the alphabet \Sigma = {a, b, c, g}, that satisfy all of the following properties: the length of the string is equal to 5n+3, for some natural number n greater or equal than 0; all of the first (leftmost) 2n symbols are elements of the set {b, c, g}; all of the last (rightmost) 3n symbols are elements of the set {a, b}; the symbols at position 2n+1, 2n+2, and 2n+3 (from the left, i.e., after the first 2n symbols but before the last 3n symbols) are elements of the set {c, g}; Write a complete formal definition of a context free grammar that generates L. If such a context free grammar does not exist, state that the context free grammar does not exist, and prove it.

Answers

Answer:

S -> LSR

S -> M

M -> YYY

Y -> c | g

L -> XX

X -> b | c | g

R -> ZZZ

Z -> a | b

Explanation:

This is a long time ago, but I think this does what you want.

Start symbol S expands to LSR and allows you to grow L and R on either side as much as you want. Ultimately S must be replaced by M. Then you have a pattern like LLLLLMRRRRR.

We can then further break down L into 2 times b, c or g, and similar for M and R.

state the function of a URL in a website​

Answers

Answer:

It's purpose is to access a webpage.

Explanation:

A URL contains detailed information on the webpage such as, the domain name, protocol, and path. This information directs the browser to the desired page.

Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer journey and maps out the kind of data they need to collect at each touch point. How does this help the client achieve their objectives?

Answers

Answer:

d. by increasing their customer knowledge and leveraging that information to improve customer experience

Explanation:

Consumers are at the heart of all businesses as they are the ones who our product are targeted. They purchase these goods and the company makes profit. Therefore, it is paramount for businesses to identify their target consumers in other to understand their preference and serve them accordingly. With data analytics, a consumers purchase history, likes and viewed products may be used to improve relationship between consumers and service providers. Once a consumer's preference is anlysed using data, then this is leveraged to improve the kind of service offered to such consumer leasing to better consumer experience.

The way in which the auditing of the client’s customer journey and mapping out the kind of data they need to collect at each touch point helps the client achieve their objectives is;

A: by updating their sales platform and adding new features

The missing options are;

A. by updating their sales platform and adding new features

B. by shifting the focus away from the customer and towards new products or services

C. by identifying products that are poor sellers and removing them from the inventory

D. by increasing their customer knowledge and leveraging that information to improve customer experience.

Looking at the given options, the one that is correct is Option A. This is because the company will by that medium, introduce new features that would be very useful in making the sales platform to be more efficient.

Now, Accenture is a company that does consultancy services by providing digital solutions to companies to help them to optimize their business operations. Thus, their different tools will help to give this their client an extra edge that will give them a good advantage over their competitors.

Read more about Accenture at; https://brainly.com/question/25702705

In this lab, you complete a C++ program that uses an array to store data for the village of Marengo.
The program is described in Chapter 8, Exercise 5, in Programming Logic and Design. The program should allow the user to enter each household size and determine the mean and median household size in Marengo. The program should output the mean and median household size in Marengo. The file provided for this lab contains the necessary variable declarations and input statements. You need to write the code that sorts the household sizes in ascending order using a bubble sort and then prints the mean and median household size in Marengo. Comments in the code tell you where to write your statements.
Instructions
Make sure that the file HouseholdSize.cpp is selected and open.
Write the bubble sort.
Output the mean and median household size in Marengo.
Execute the program by clicking the Run button and the bottom of the screen.
Enter the following input, and ensure the output is correct. Household sizes: 4, 1, 2, 4, 3, 3, 2, 2, 2, 4, 5, 6 followed by 999 to exit the program.
Here is my code so far. I need help finishing it (printing the mean & median, etc). Thanks so much:
// HouseholdSize.cpp - This program uses a bubble sort to arrange up to 300 household sizes in
// descending order and then prints the mean and median household size.
// Input: Interactive.
// Output: Mean and median household size.
#include
#include
using namespace std;
int main()
{
// Declare variables.
const int SIZE = 300; // Number of household sizes
int householdSizes[SIZE]; // Array used to store 300 household sizes
int x;
int limit = SIZE;
int householdSize = 0;
int pairsToCompare;
bool switchOccurred;
int temp;
double sum = 0;
double mean = 0;
double median = 0;
// Input household size
cout << "Enter household size or 999 to quit: ";
cin >> householdSize;
// This is the work done in the fillArray() function
x = 0;
while(x < limit && householdSize != 999)
{
// Place value in array.
householdSizes[x] = householdSize;
// Calculate total of household sizes
sum+= householdSizes[x];
x++; // Get ready for next input item.
cout << "Enter household size or 999 to quit: ";
cin >> householdSize;
} // End of input loop.
limit = x;
// Find the mean
// This is the work done in the sortArray() function
pairsToCompare = limit - 1;
switchOccured = true;
while(switchOccured == true)
{
x = 0;
switchOccured == false;
while (x < pairsToCompare)
{
if(householdSizes[x]) > householdSizes[x+1])
{
//perform switch
}
x++;
}
pairsToCompare--;
}
// This is the work done in the displayArray() function
//Print the mean
// Find the median
median = (limit-1) / 2;
if (limit % 2 ==0)
{
cout << "Median is: " << (householdSizes[(int)median] + householdSizes[(int)median + 1]) / 2.0 << endl;
}
else {
// Print the median household size
}
// Print the median
return 0;
} // End of main function

Answers

Answer:

For the mean, do the following:

mean = sum/limit;

cout<<"Mean: "<<mean;

For the median do the following:

for(int i = 0; i<limit; i++) {

  for(int j = i+1; j<limit; j++){

     if(householdSizes[j] < householdSizes[i]){

        temp = householdSizes[i];

        householdSizes[i] = householdSizes[j];

        householdSizes[j] = temp;       }    } }

median= (householdSizes[(limit-1)/2]+householdSizes[1+(limit-1)/2])/2.0;

if((limit - 1)%2==0){

   median = householdSizes[limit/2];

}

cout<<endl<<"Median: "<<median;

Explanation:

The bubble sort algorithm in your program is not well implemented;

So, I replaced the one in your program with another.

Also, some variable declarations were removed (as they were no longer needed) --- See attachment for complete program

Calculate mean

mean = sum/limit;

Print mean

cout<<"Mean: "<<mean;

Iterate through each element

for(int i = 0; i<limit; i++) {

Iterate through every other elements forward

  for(int j = i+1; j<limit; j++){

Compare both elements

     if(householdSizes[j] < householdSizes[i]){

Reposition the elements if not properly sorted

        temp = householdSizes[i];

        householdSizes[i] = householdSizes[j];

        householdSizes[j] = temp;       }    } }

Calculate the median for even elements

median= (householdSizes[(limit-1)/2]+householdSizes[1+(limit-1)/2])/2.0;

Calculate the median for odd elements

if((limit - 1)%2==0){

   median = householdSizes[limit/2];

}

Print median

cout<<endl<<"Median: "<<median;

Describe Technology class using at least 3 adjectives

Answers

Answer:

clearly alien

typically inept

deadly modern

Explanation:

What lets you do many things, like write book reports and stories?

Application Programs

Antivirus Software

Email

Duct Tape

Answers

A -
Application programs
application progarms lets you do many things

what would be the result of running these two lines of code


Ski

Surf

Jog

Hike

Answers

Answer:

Jog

Explanation:

The variable options is a list containing 5 string values

options = ["ski", "surf", "jog", "bike", "hike"]

Indexing in python starts from 0 ; hence the index values of the list values are :

0 - ski

1 - surf

2 - jog

3 - bike

4 - hike

The statement ;

print(options[2]) means print the string at index 2 in the list named options

The string at index 2 is jog ;

Hence, the string jog is printed.

In which SDLC step does the company translate broad, user-oriented systems requirements into the detailed specifications used to create a fully developed system

Answers

Answer:

Physical design.

Explanation:

Systems development life cycle (SDLC) is a strategic process that involves determining the overall system architecture, which is typically comprised of hardware, end users, physical processing components, software, and the communication channel that will effectively and efficiently satisfy the essential requirements of the system.

The system inputs and outputs is typically designed along with a plan of how the system's features will be navigated.

Basically, system design is divided into two (2) categories and these includes;

I. Logical design.

II. Physical design.

Furthermore, the design of service systems involves the process of planning, creating infrastructure, building communication, organizing staffs and standardization of a system so as to improve its quality and business relationships between the service provider and its clients.

In the physical design of systems development life cycle (SDLC), broad, user-oriented systems requirements are obtained from end users by companies and then translated into the detailed specifications that would be used to create a fully developed system.

Advancements in technology often make computer
hardware and software more convenient to use as
well as able to fit a variety of budgets. As
technology advances, it usually gets
smaller and less expensive.
larger and more expensive.

Answers

Answer: smaller and less expensive.

Explanation:

As technology advances, the architects of the devices that we use are getting more efficient in the production of said devices such that they are using better materials and techniques in production.

This has led to a situation where devices are increasingly getting smaller in size and cheaper to afford as well. For instance, compare the computers of today to those of the 90's. We have laptops now which are really slim and cost a fraction of what the bulky computers of those days cost.

LaToya is creating a program that will teach young children to type. What keyword should be used to create a loop that will print “try again” until the correct letter is typed
a. print

b. random

c. else

d. while

Answers

Question:

LaToya is creating a program that will teach young children to type. What keyword should be used to create a loop that will print “try again” until the correct letter is typed

Answer:

d. while ✓

Explanation:

The while loop is used to repeat a section of code an unknown number of times until a specific condition is met.

[tex] \\ \\ [/tex]

Hope it helps

-------☆゚.・。゚ᵴɒƙυᴚᴀ_ƨȶäᴎ❀

Write a function that accepts a positive random number as a parameter and returns the sum of the random number's digits. Write a program that generates random numbers until the sum of the random number's digits divides the random number without remainder. assembly language

Answers

Answer:

Explanation:

The following Python program has a function called addDigits which takes a number as a parameter and returns the sum of the digits. Then the program creates a loop that keeps creating random numbers between 222 and 1000 and divides it by the value returned from the function addDigits. If the remainder is 0 is prints out a statement and breaks the loop, ending the program. The picture below shows the output of the program.

import random

def addDigits(num):

   sum = 0

   for x in str(num):

       sum += int(x)

   return sum

sum = addDigits(random.randint(222, 1000))

while True:

   myRandomNum = random.randint(2, 99)

   if (sum % myRandomNum) == 0:

       print("No remainder between: " + str(sum) + " and " + str(myRandomNum))

       break

which data type uses %i as a format specifier​

Answers

Answer:

A decimal integer

Explanation:

Hope this helps!

Which programming paradigm does the programming language JavaScript follow?
A. procedural programming
B. object-oriented programming
C. functional programming
D. Imperative programming​

Answers

Its not functional programming (sorry)

Answer:

Object-oriented programming

Explanation:

Just took the test and got it right

Happy to help !!

What is a
a program​

Answers

Answer:

-a collection of related measures or activities aimed at achieving a specific long-term goal.

-a set of pre-programmed software instructions for controlling the operation of a computer or other machine

-provide (a computer or other machine) with pre-programmed instructions for completing a task automatically

-Organize according to a schedule or plan.

Explanation:

Answer:

A program is an set of instructions given by a computer to perform particular task

3. Why is human resource plan made​

Answers

Answer: See explanation

Explanation:

Human Resource Planning refers to the process whereby the future human resource requirements of an organization is predicted and how the current human resources that the organization has can be used to fulfill the goals.

Human resources planning is made as it's useful helping an organization meet its future demands by supplying the organization with the appropriate people.

Human resource planning also allows organizations plan ahead in order to have a steady supply of effective and skilled employees. It also brings about efficient utilization of resources. Lastly, it leads to better productivity and organizational goals will be achieved.

In the header element, insert a navigation list containing an unordered list with the items: Home, Race Info, and FAQ. Link the items to the dr _index.html, dr_info.html, and dr_ faq.html files respectively.
Home
Race info
FAQ

Answers

Answer:

Explanation:

The following is a barebones HTML document that contains the Unordered List inside the header tag as requested. The list items are also wrapped around links so that they link to the requested pages and take you there when they are clicked. These html files need to be in the same folder as this code in order for it to take you to those pages. The code can be seen below.

<!DOCTYPE html>

<html>

<head>

<ul>

   <li><a href="dr _index.html">Home</a></li>

   <li><a href="dr_info.html">Race Info</a></li>

   <li><a href="dr_ faq.html">FAQ</a></li>

</ul>

</head>

<body>

</body>

</html>

type of operating system used i handleheld device

Answers

Answer:

6

Explanation:

Palm OSPocketOSSymbianOSLinuxOSWindowsAndroid

Synapse is not working and is crashing every time you attach it. What should you do?

1. Contact a staff
2. Wait for it to be fixed
3. delete it
4. Spam dm everyone

Answers

Contact a staff memeber

17. Which of the following keyboard shortcut is used to copy the selected text?
a. Ctrl+c
b. Ctrl+V
c. Ctrl+X
d. Ctrl+Z​

Answers

Answer:

ctrl+c is used to copy the selected text

Answer:

A. Ctrl+c

Explanation:

I took the test, also you can use Command c and Command v to copy and paste.

A local router is configured to limit the bandwidth of guest users connecting to the Internet. Which of the following best explains the result of this configuration as compared to a configuration in which the router does not limit the bandwidth?

a. The amount of time it takes guest users to send and receive large files is likely to decrease.
b. The number of packets required for guest users to send and receive data is likely to decrease.
c. Guest users will be prevented from having fault-tolerant routing on the Internet.
d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Answers

Answer:

The correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Explanation:

Bandwidth can be described as the maximum data transfer that an internet connection or a network has. It gives a measure of the amount of data that can be transmitted over a particular connection in a particular amount of time. For instance, the capacity of a gigabit Ethernet connection is 1,000 megabits per second (Mbps) (which also translates to 125 megabytes per second).

Therefore, when a local router is configured to limit the bandwidth of guest users connecting to the Internet, it will restrict the the maximum amount of data that they can transmit per second.

Therefore, the correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Amy’s new summer job at the pool will put $9 per hour. Which term describes this type of hourly income?
A. Salary
B. Take-home pay
C. Wage
D. All of the above

Answers

Answer:

d

Explanation:

Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volume of a pyramid with a rectangular base. calcPyramidVolume() calls the given calcBaseArea() method in the calculation.

Answers

Answer:

The method in C++ is as follows:

double calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight){

   double baseArea = calcBaseArea(baseLength, baseWidth);

   double volume = baseArea * pyramidHeight;

   return volume;    

}

Explanation:

This defines the calcPyramidVolume method

double calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight){

This calls the calcBaseArea method to calculate the base area of the pyramid

   double baseArea = calcBaseArea(baseLength, baseWidth);

This calculates the volume

   double volume = baseArea * pyramidHeight;

This returns the volume

   return volume;  

}

See attachment for complete program that include all methods that is required for the program to function.

how do computers help us with our homework​

Answers

A computer can be helpful in completing homework because it gives you access to lots of sources of information like graphing websites, calculators, educational games & programs that can help you. It also allows for an easier process to submit work, organize papers, & presentations.

xD I don't know if you said this as a joke, or if you're serious, but here:

A computer can be a helpful tool to complete your homework by giving you access to countless sources of information, it can also provide you with educational games which can enhance a child's learning ability by presenting learning as something fun and interactive as opposed to boring loads of repeated work which barely stimulate learning at all. But keep in mind that a computer can also take the opposite effect on a child's brain, and can gradually turn into addiction.

I hope this helps! :D

(FYI, I spent an unreasonable amount of time typing this all in, so I hope it makes any difference at all :P)

Other Questions
someone help please hey! ill give brainliest please help What is the molarity of a solution containing 9.0 moles of solute in 462 mL of solution Johnny says he will not drive above the speed limit simply because he does not want to pay the cost of a speeding ticket. Based on this information, it can be concluded that Johnny is operating at the _____ stage of Kohlberg's theory of moral reasoning. An electric field has a positive test charge of 5.00 C placed in it. The force on the test charge is6.000 N. The magnitude of the electric field at the location of the test charge iso 30.0 NVC0 1.20 N/C0 120, NVCO 3.00 N/C01.02 N/C Write a quadratic function in vertex form whose graph has the vertex (1, 0) and passes through the point (2, 17) .f(x)= If 5x + 2 = 17, then 12x =____? 27. Spanish conquistadors were less interested in the Mayan civilization than the AztecEmpire because the Mayans had a - Find the lengths of a square having area 676cm2 Read this dictionary entry.lead (leed) noun1. the first or foremost place 2. a leash 3. a piece of information that helps guide; a tip or clue 4. a guide or indication of a road or courseRead this sentence from the article.While giving tours, he spotted many leads off the main passages.Which meaning best fits the way the word leads is used in the sentence above?F. meaning 1G. meaning 2H. meaning 3I. meaning 4Please help if i dont score 70% or higher im gonna stay back 2. A guy wire is attached to the top of a radio tower to help support it. The toweris 72 feet tall and the wire is attached to the ground 50 feet from the midline ofthe tower. Find the length of the guy wire to the nearest foot. There are 15 plates in the kitchen cabinet. The diameter of each plate is either 9 inches or 12 inches. The diameter of all 15 plates combined is 150 inches.Which system of equations can be used to find the number of 9-inch plates, x, and the number of 12-inch plates, y, that are in the cabinet? Can anybody help a brother out real quick? Would really appreciate that. Lines A and B are parallelA1/23/125B5/67/8m 6 = [ ?] King Charles came to the throne inexperiencedbut had this to his advantage.A. Kingly heritageB. A strong queenC. Military experience During which step of the writing process are the following questions asked? Do my ideas make sense? Have I arranged my ideas in the best order? Do I need to add or delete any information from my draft?RevisingEditingPrewritingPublishing In response to the Heinz dilemma, David says, "Its a natural thing for Heinz to want to save his wife, but its still his duty as a citizen to obey the law." David is most likely in the stage of __________ orientation. Which expression represents the area of the square?A: 4.4B:2+4C:2.4Or C: 4+ 4 help pls? In the morning, the temperature was 10C. By the afternoon, it had risen to 2C. What was the change in temperature from the morning to the afternoon? explain why it is important to cool down after exercise