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
Aleksandr-060686 [28]
3 years ago
10

Write a program that reads the contents of a file named text.txt and determines the following: The number of uppercase letters i

n the file The number of lowercase letters in the file The number of digits in the file Prompts And Output Labels. There are no prompts-- nothing is read from standard in, just from the file text.txt. Each of the numbers calculated is displayed on a separate line on standard output , preceded by the following prompts (respectively): "Uppercase characters : ", "Lowercase characters : ", "Digits: ". Input Validation. None.
Computers and Technology
1 answer:
murzikaleks [220]3 years ago
3 0

Answer:

Explanation:

//Cpp program to count Uppercase, Lowercase, Digits count from file

#include<iostream>

#include<fstream>

using namespace std;

int main()

{

  //ifstream For reading file purpose only

ifstream file("text.txt");

 

  //cheks whether given file is present or not

  if(!file){

      cout<<"File not Found";

      return 0;

  }

  //variables for all three counts and character in file

char character;

int uppercaseCount=0, lowercaseCount=0, digitsCount=0;

  //loop for reading and checkile file character by character

while(file){

      //get a single character

file.get(character);

 

      //checks uppercase character

if((character >= 'A') && (character <= 'Z'))

uppercaseCount++;

     

      //checks lowercase character

 else if((character >= 'a') && (character <= 'z'))

lowercaseCount++;

     //checks lowercase character

      else if((character >= '0') && (character <= '9'))

      digitsCount++;

}

cout<<"\nUppercase characters: "<<uppercaseCount;

cout<<"\nLowercase characters: "<<lowercaseCount;

cout<<"\nDigits: "<<digitsCount;

return 0;

}

/*

content of File text.txt

C++

10.15: Character Analysis Write a program that reads the contents of a file named text.txt and determines the following: The number of uppercase letters in the file The number of lowercase letters in the file The number of digits in the file Prompts And Output Labels. There are no prompts-- nothing is read from standard in, just from the file text.txt. Each of the numbers calculated is displayed on a separate line on standard output, preceded by the following prompts (respectively): "Uppercase characters: ", "Lowercase characters: ", "Digits: ". Input Validation. None.

Output :-

Uppercase characters: 19

Lowercase characters: 434

Digits: 4

*/

You might be interested in
What is the main function of the motherboard?
djyliett [7]

Answer: The MotherBoard is an essential component or part of a computer. It includes some of the important parts which are CPU, memory, connection of inpit and output devices.

Explanation:

5 0
4 years ago
Which popular tool is used in agile software development TCS?
weqwewe [10]

Answer:

Atlassian's Jira is the popular tool.

Explanation:

Atlassian's Jira is a popular tool used in agile software development and a prevalent project management program.

It is used by 180,000 people and in 90 Countries.

8 0
2 years ago
Detrmine whether the following pairs of lines are paralles , perpendialor or neither. 8x+9y=5 and 4x+2y=7 Y=2x-4 and y=4x-2 X=9
Vladimir [108]

Answer:

perpendicular for the first one

4 0
3 years ago
Of the following common metals which has the highest conductivity rating?
never [62]

Answer: D. Silver (happy to help)

Explanation:

3 0
3 years ago
Read 2 more answers
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
Delvig [45]

Answer:

// program in java.

import java.util.*;

// class definition

class Main

{

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input  

Scanner scr=new Scanner(System.in);

 System.out.print("Enter the String:");

  // read string from user

   String str=scr.nextLine();

System.out.print("Enter the character:");

 // read character

char ch=scr.next().charAt(0);

  // variable to count the occurrence of character  

   int char_count=0;

   for(int i=0;i<str.length();i++)

   {

   // find the character i string

       if(ch==str.charAt(i))

       // increase the count

       char_count++;

   }

   // print the count

   System.out.println("count of "+ch+" in the String is:"+char_count);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read a string from user and assign it to variable "str".Then read a character to  and assign it to variable "ch".Then Declare a variable "char_count" to count the  occurrence of character in the string.Find the count of character in the string. Here upper case character is different than lower case.  

Output:

Enter the String:Monday                                                                                                    

Enter the character:n                                                                                                      

count of n in the String is:1

Enter the String:Nobody                                                                                                    

Enter the character:n                                                                                                      

count of n in the String is:0                                                                                              

                             

5 0
3 years ago
Other questions:
  • An electronic resume is a plain-looking document. True of False?
    6·2 answers
  • How are the stop lamp bulbs connected in relation to each other? a. In parallel. b. In series. c. In series/parallel. d. None of
    13·1 answer
  • Suppose in a class of 100 students, there is a homework due every week. The professor wants to encourage students to hand in the
    8·1 answer
  • Computer a has an overall cpi of 1.3 and can be run at a clock rate of 600mhz. computer b has a cpi of 2.5 and can be run at a c
    11·1 answer
  • I have six nuts and six bolts. Exactly one nut goes with each bolt. The nuts are all different sizes, but it’s hard to compare t
    12·1 answer
  • Signs that a listener is paying attention include:
    10·2 answers
  • A bug was discovered in Canvas where the website crashes if 2 or more students are writing a discussion post at the same time. I
    10·1 answer
  • Data are sent through a network on bundles called _______. select one:
    8·2 answers
  • 1. Answer the following questions: a. What are the different types of number system? Name them.​
    8·1 answer
  • 9.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!