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
Illusion [34]
2 years ago
11

Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character o

f each sentence capitalized. The program should let the user enter a string and then pass it to the function, printing out the modified string.
Computers and Technology
1 answer:
soldi70 [24.7K]2 years ago
3 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 System.out.println("Enter String");

 Scanner sc1=new Scanner(System.in);

 String st1=sc1.nextLine();

 convertfirstchartoupper(st1);

 //System.out.println(st1);

 

}

private static void convertfirstchartoupper(String st1){

     

      char[] arr = st1.toCharArray();

      int k =0;

      arr[0]=Character.toUpperCase(arr[0]);

      while(k<arr.length)

      {

         

         if(Character.isWhitespace(arr[k]))

         {

             

             arr[k+1]=Character.toUpperCase(arr[k+1]);

             

         }

         

         

        k++;

      }

      k=0;

       while(k<arr.length)

      {

         

        System.out.print(arr[k]);

         

        k++;

      }

  }

}

Explanation:

In the above java program, we change a string into an array of characters and then check for whitespace. the letter next to while space is the first letter of the new word, and hence we capitalize that letter. And this is what is required. However, we can split the sentence into a string of words as well, and then capitalize the first letter of each word.

You might be interested in
List 5 ways that computers could be used in a school or university
larisa [96]

Answer:

Explanation:

✓ computer can be used Interactive Learning apps, whereby students can share knowledge

✓Access to Information on the go: computer can be searched when educational information is needed

✓Virtual Classrooms : Incase of online classroom computer can be of help where both teacher student can meet online

✓Data processing and presentation ; computer can be used by both teacher and student in processing of data's.

✓Computer Literacy Education : for Literacy Education, computer can be used in training students to become computer literate.

4 0
3 years ago
Write a program (using functions) starting from directives to compute and display the transpose of a matrix of dimension m x n.
pentagon [3]

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

int m, n;

void transpose(int matrix[]){

  int transp[m][n];

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

     for (int j = 0; j < m; j++){

        transp[j][i] = matrix[i][j];

        cout<< transp[j][i]<< " ";

     }

     cout<< "\n";

  }

}

int main(){

  cout<< "Enter the value for n: ";

  cin>> n;

  cout>> "Enter the value for m: ";

  cin>> m;

  int mymatrix[n][m];

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

     for (int j = 0; j < m; j++){

        mymatrix[i][j] = (rand() % 50);

     }

  }

  transpose(mymatrix);

}

Explanation:

The C source code defined a void transpose function that accepts a matrix or a two-dimensional array and prints the transpose on the screen. The program gets user input for the row (n) and column (m) length of the arrays. The C standard library function rand() is used to assign random numbers to the array items.

3 0
3 years ago
Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem
Nat2105 [25]

Answer:

The program to this question can be given as:

Program:

#include<stdio.h>  //header file.

int main()

 //main function

{

   int SCORES_SIZE = 4;  //define variables.

   int bonusScores[]={10,20,30,40};  //define array.

   int i;

   printf("Values:");

 //message

   for (i = 0; i < SCORES_SIZE; ++i)  //loop for print values.

   {

       printf("%d ", bonusScores[i]);

   }

void CombineScores(int numberScore, int userScore) //function

{

   for (i = 0; i < SCORES_SIZE; i++)

  //loop for convert values

   {

       if (( bonusScores[i] <= bonusScores[i +1] ) || (bonusScores[i] < bonusScores [i+1]))  //check array elements

       {

           bonusScores[i] = (bonusScores [i] + bonusScores[i+1]);

 //add values

       }

       else

       {

           bonusScores[i] = bonusScores[i];

       }

   }

   printf("\nReturn values:");  //message

 for (i = 0; i < SCORES_SIZE; i++)

{

printf("%d",bonusScores[i]);

}

}

CombineScores(0,0); //calling

return 0;

}  

Output:

Values:10 20 30 40  

Return values:30 50 70 40  

Explanation:

In the above c++ programming code firstly we define the header file. Then we define the main function in this function we define variable that name is given in the question that is SCORES_SIZE, i. Variable i is used in the loop for a print array. Then we define and initialize an array. The array name is and elements are define in the question that is bonusScores[]={10,20,30,40}. Then we use the loop for print array elements.Then we define function that is CombineScores() in this we pass two parameter. Then we use the second time in this loop we check array elements and add the elements that are given in the question. In this function we print values and at the end we call function.

3 0
3 years ago
I play Among us :) hbu
11Alexandr11 [23.1K]

Answer:nice

Explanation:u tryna play doe?

7 0
3 years ago
Read 2 more answers
Today's networks can offer differing levels of ________, which include specifications for maximum delay and minimum throughput
xeze [42]
The answer is quality service. 
Today's networks can offer different levels of quality service, which include specifications for a maximum delay and minimum throughput. Quality service or QoS requirements in terms of the maximum allowed delay jitter for such applications.  Quality of Service is the set of techniques to manage network resources.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Subana is writing a program which will calculate the mean average of a set of numbers by adding the numbers and dividing the res
    12·1 answer
  • Which of the following is designed to help an organization continue to operate during and after a disruption?
    12·1 answer
  • In windows, a(n) ________ follows the file name and a period and indicates the file type.
    9·1 answer
  • c++ Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins wi
    8·1 answer
  • Camera lenses typically have very long focal points. true or false.
    5·2 answers
  • All of these (except the ______) go unnoticed by the computer
    7·1 answer
  • If anyone know python code, your answer will be valuable.
    12·2 answers
  • What is a key differentiator of Conversational Artificial Intelligence (AI)
    11·1 answer
  • An IT security threat is anything that might cause serious harm to a computer system.
    9·1 answer
  • I really need the answer now!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!