1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
malfutka [58]
3 years ago
9

Complete the firstMiddleLast() function to return a new string with the first, middle, and last character from string. If string

has an even number of characters, grab the middle two characters. It is safe to assume that no string passed in will be less than 3 characters.
Computers and Technology
1 answer:
morpeh [17]3 years ago
4 0

public static void main()

{

String s = Console.ReadLine();

int len = s.length();

Char startletter = s[0];

Char endletter = s[len-1];

string midletter = ‘’;

if(len % 2 ==0)

midletter = s[len/2] + s[(len/2) +1]

else

midletter = s[len/2];

Console.WriteLine(startletter + midletter + endletter);

}

Here the logic is that, startletter is obtained using the index ‘0’, the last letter is obtained by calculating the “length of the string” and subtract 1 to get the “last index” of the given string.

Middle letter is calculated by first finding whether the given string length is “odd or even” and based on that index(es) are identified.

You might be interested in
What do you think entertainment or gaming platforms will look like in the future?
anzhelika [568]

Answer:

In early 2019, Netflix CEO Reed Hastings told shareholders what he thought was the company’s

8 0
3 years ago
NEED ASAP!!
kow [346]

Answer:

because he needs to connect them all to the sane network (i think)

4 0
3 years ago
I can't see the answer
Ilia_Sergeevich [38]
Cant see what answer theres no pic or anything?
7 0
3 years ago
Read 2 more answers
Tara has found a CTSO she’s interested in joining. How can Tara become a member of the CTSO? Tara can become a member of the CTS
Alex787 [66]
I'm not understanding this question, are there any options for the answer?
3 0
3 years ago
Read 2 more answers
Write a C++ program that reads students' names followed by their test scores. The program should output each students' name foll
Mashutka [201]

Answer:

#include<iostream>

#include<conio.h>

using namespace std;

struct studentdata{

char Fname[50];

char Lname[50];

int marks;

char grade;

};

main()

{

studentdata s[20];

for (int i=0; i<20;i++)

   {

cout<<"\nenter the First name of student";

cin>>s[i].Fname;

cout<<"\nenter the Last name of student";

cin>>s[i].Lname;

cout<<"\nenter the marks of student";

cin>>s[i].marks;

}  

 

for (int j=0;j<20;j++)

{

if (s[j].marks>90)

{

 s[j].grade ='A';

}

else if (s[j].marks>75 && s[j].marks<90)

{

   s[j].grade ='B';

}

else if (s[j].marks>60 && s[j].marks<75)

{

 s[j].grade ='C';

}

else

{

 s[j].grade ='F';

}

}

int highest=0;

int z=0;

for (int k=0;k<20; k++)  

{

if (highest<s[k].marks)

{

 highest = s[k].marks;

 z=k;

}

 

}

cout<<"\nStudents having highest marks"<<endl;

 

cout<<"Student Name"<< s[z].Fname<<s[z].Lname<<endl;

cout<<"Marks"<<s[z].marks<<endl;

cout<<"Grade"<<s[z].grade;

getch();  

}

Explanation:

This program is used to enter the information of 20 students that includes, their first name, last name and marks obtained out of 100.

The program will compute the grades of the students that may be A,B, C, and F. If marks are greater than 90, grade is A, If marks are greater than 75 and less than 90, grade is B. For Mark from 60 to 75 the grade is C and below 60 grade is F.

The program will further found the highest marks and than display the First name, last name, marks and grade of student who have highest marks.

6 0
3 years ago
Other questions:
  • In the two-level directory, if a user refers to a particular file then__________________ Select one: a. only his/her own UFD (us
    7·1 answer
  • Considers the assets of all things in an environment, and refers to the layering of security tools and methods often varying num
    13·1 answer
  • List seven basic internal components found in a computer tower
    13·1 answer
  • This is not based on homework but I have a question. I am currently using a gtx 960 with a 6 core amd processor. Does anyone kno
    6·1 answer
  • Which of the choices Sean are not true when considering virus behavior
    9·1 answer
  • Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructo
    12·1 answer
  • How do you think someone has programmed computer calculator?​
    13·1 answer
  • Describe how to create a new folder on the desktop​
    12·2 answers
  • Intelligent transportation systems use GPS to<br> Select all that apply.
    5·1 answer
  • CISC vs RISC processors might be used, and come up with environments where one processor would outperform the other.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!