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
irina1246 [14]
3 years ago
6

Hey all! How would you write write this code?

Computers and Technology
1 answer:
Kamila [148]3 years ago
4 0

The program is an illustration of loops.

Loops are used to perform repetitive actions.

The program in C++ where comments are used to explain each line, is as follows:

#include <string>

#include <iostream>

using namespace std;

int main(){

   //This declares all variables

   int n, count = 0; string k;

   //This gets input for the number of cards

   cin>>n;

   //The following is repeated n-times

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

       //This gets input for the current card value

       cin>>k;

       //If the card is a digit

       if(isdigit(k[0])){

           //This checks if the card number is between 2 and 6 (inclusive)

           if(stoi(k) >= 2 && stoi(k) <= 6){

               //If yes the face value is increased by 1

               count+=1;

           }

           //This checks if the card number is 10

           else if(stoi(k) == 10){

               //If yes the face value is decreased by 1

               count-=1;

           }

       }

        //This checks if the card number is J, Q, K or A

       else if (k == "J" || k == "Q" || k == "K" || k == "A") {

           //If yes the face value is decreased by 1

           count-=1;

       }

   }

   //This prints the face value

   cout<<count;

   return 0;

}

At the end of the program, the face value is printed.

Read more about similar programs at:

brainly.com/question/24578223

You might be interested in
It is essential that a security professional is able to resolve and respond to cyber law inquiries and incidents while avoiding
Y_Kistochka [10]

Answer:

The laws and regulations will often define sensitive or protected data and the reporting requirements in the case of a data breach. Failure to follow the prescribed process can often result in fines or other penalties.

Explanation:

These data security laws should be standardized worldwide in order to stop internet abuses.

5 0
4 years ago
Give three facts about the history of the train shongololo
monitta
<span>began operating in 1995
shongololo means </span><span> “to roll up”
non- profit organization </span>
3 0
4 years ago
Which one of the following UNIX utilities is purpose-built to quickly return the location (filepath) of files by querying a data
Galina-37 [17]

Answer:

a.locate

Explanation:

locate utility in Unix is used to quickly return the filepath of the file searched for.find also used to do the same work but it is not as fast as locate.

locate is faster than find because it does not read the filesystem to search the file infact it refers to the database to search the file and produces it's output and the database is created by updatedb command.

4 0
3 years ago
How to jailbreak ios 9.2 ? Is there anyway???!!!!
Leviafan [203]
Use Pangu 9.2 iOS jailbreak installer.
1. get the Pagnu 9.2 installer
2. connect your iOS 9.2 device to your Windows/OS X machine via universal serial bus cord
3. go through with the setup wizard
6 0
3 years ago
Create an application (that uses the SortedABList) that allows a user to enter a list of countries that he or she has visited an
gulaghasi [49]

Answer:

import java.util.*;

public class Country

{

  public static void main(String args[])

  {

      char ch,temp;

      int flag = 0;

      String country;

      ArrayList<String> countries = new ArrayList<String>();

      Scanner sc = new Scanner(System.in);

      do

      {

          System.out.println("enter the country you have visited:\t");

          country = sc.next();

          for(int i=0;i<countries.size();i++)

          {

              if(countries.get(i).equals(country))

              {

                  System.out.println("you have already entered the country");

                  flag = 1;

                  break;      

              }

          }

          if(flag == 0)

          {

              countries.add(country);

              flag = 0;

          }

          System.out.println("want to add another country(y/n):\t");

          ch = sc.next().charAt(0);

      }while(ch!='n');

      Collections.sort(countries);

      System.out.println("Countries you have visited:\t"+countries);

      System.out.println("Total number of contries visited:"+countries.size());

     

  }

}

Explanation:

8 0
4 years ago
Other questions:
  • Please help!
    10·2 answers
  • Additional rows and columns are inserted into a table by using the _____ tab
    7·2 answers
  • Which of the following is the definition of Internet Protocol Security ( IPSec)? A remote access client/server protocol. It is a
    13·2 answers
  • Which of the following apply to the definition of Wide Area Networks? Check all of the boxes that apply.
    7·2 answers
  • Which tab should you choose to add a picture from a file to your presentation?
    8·1 answer
  • To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method.
    8·1 answer
  • Dgvdsgf cvdzgb fgvsdxchygfdrzvdszfgvsdzxd
    9·1 answer
  • Readable code
    12·2 answers
  • V. ASSESSMENT (Time Frame:
    7·1 answer
  • What are the most common processes and procedures handled by data warehousing specialists? select all that apply.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!