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
kap26 [50]
2 years ago
10

Write a program to assign and display a string value to any variable of your choice

Computers and Technology
1 answer:
vazorg [7]2 years ago
6 0

Answer:

How to create a string and assign it to a variable. To create a string, put the sequence of characters inside either single quotes, double quotes, or triple quotes and then assign it to a variable.

You might be interested in
Which of the following is not a concern that has come out of the widespread adoption of the Internet?
slamgirl [31]

Answer:

The correct option is;

Selecting the correct browser to use for the sites you want to visit

Explanation:

Censorship of information is the subduing of information based on the consideration of such information being harmful or inconvenient

Increased anonymity

Making an individual anonymous which is one of the capabilities of the internet, is seen as encouraging unethical behavior and promoting discussions which are deemed uncivil in a commonly shared space online.

Unauthorized sharing of copyrighted information

The sharing and distribution of copyrighted material is against the law but it is a common occurrence and in various formats online

Out of the given options, selecting the correct browser to use for the sites you want to visit is the one that is not a concern.

5 0
2 years ago
Write a program that simulates a lottery. The program should havean array of five integers named lottery, and shouldgenerate a r
Fiesta28 [93]

Answer:

Here is the C++ program that simulates lottery:

#include<iostream>  //to use input output functions

using namespace std;  //to access objects cin cout

int main(){  //start of main function

int size= 5; // size of arrays

int range = 10;  //range of random numbers from 0 to 9

int user[size];  // user array

int lottery[size];  // lottery array

for(int i=0;i<size;i++)  //iterates through the array

lottery[i]=rand()%range;  // generates random number in specified range

cout<<"Enter "<<size<<" digits: ";  //prompts user to enter 5 digits

for(int i=0;i<size;i++)  //loops through the user array

cin>>user[i];  //reads input digits from user

int match=0;  //stores number of matching digits

for(int i=0;i<size;i++)  //iterates through array to compare user and lottery arrays

if(user[i]==lottery[i])  //if digit at i-th index of user array matches to that of lottery array

match++;  //increments count of matching digits by 1

cout<<"Lottery array: ";  // display digits of lottery array

for(int i=0;i<size;i++)  //iterates through elements of lottery array

cout<<lottery[i]<<" ";  //prints elements of lottery array with a space between them

cout<<endl;  //prints a new line

cout<<"  User  array: ";  // prints digits of user array

for(int i=0;i<size;i++) //iterates through elements of user array

cout<<user[i]<<" ";  //prints elements of user array

cout<<endl;  // prints a new line

if(match==size){  //if all the digits match

cout<<"Congratulations. You are a grand prize winner! "; }//displays this message proclaiming the user as a grand prize winner

else{  // if all digits of user array do not match with lottery array digits

cout<<"Number of digits matched: "<<match<<endl; //displays the number of matched digits

cout<<"Sorry! Better luck next time!" ;    //displays this message when all digits don't match

}

}    

Explanation:

If you want to keep the size and range fixed then you can use #define before the main() function to give a constant value to size and range as:

#define size 5

#define range 10

The program uses rand() function in order to generate random numbers for lottery array in the range of 0 through 9.

Then the program declares a user array with size = 5 and prompts user to enter 5 digits to stores in user array.

Next the program matches each digit of user array to the corresponding digit of lottery array and if the two digits match then the program increments the match variable by 1 to count the matched digits. For example, lets say lottery has the following elements:

lottery: 7,4,9,1,3

Lets say user array has following elements input by user at console

user: 4,2,9,7,3

Now at first iteration the digit 7 at 0-th index of lottery array is matched to the digit 4 at 0-th index of user array. This index is specified using variable i. These means the first element of lottery array is matched with first element of user array. As these digits are not equal so they don't match and the variable i is incremented to point to the position of next digit.

Now at second iteration the digit 4 in lottery array is matched to the digit 2 of user array. As these digits are not equal so they don't match and the variable i is incremented.

at third iteration the digit 9 in lottery array is matched to the digit 9 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 1

Now at fourth iteration the digit 1 in lottery array is matched to the digit 7 of user array. As these digits are not equal so they don't match and the variable i is incremented. The value of match also remains the same i.e. 1

at fifth iteration the digit 3 in lottery array is matched to the digit 3 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 2

Next the loop ends because the value of exceeds 5 which is the size of the array.

Next if(match==size) statement has an if condition which checks if all digits match. This is checked by comparing the count of match variable to the size of the array. The value of match is 2 and value of size is 5 so this means that all the digits do not match. Hence this condition evaluates to false. So the statement in if part will not execute and program moves to the statement: cout<<"Number of digits matched: "<<match<<endl; which displays the value of match variable i.e. 2 as:

Number of digits matched: 2

followed by statement cout<<"Sorry! Better luck next time!" ;  which displays the message:

Sorry! Better luck next time!

5 0
2 years ago
Once jaden has decided upon the telecommunications technology his team will use, he will have completed the last step of the dec
mrs_skeptik [129]
<span>Once Jaden has decided upon the telecommunications technology his team will use, he will have completed the last step of the decision-making process. TRUE.</span>
6 0
3 years ago
Keyword stuffing is considered to be a black hat technique for SEO and is highly suggested today by Google.
klemol [59]

Answer:

False

Explanation:

Keyword stuffing is a practice to insert an unusual large number of tag in a website to increase the page ranking in search results. This is considered an unethical Search Engine Optimization (SEO).

Google consider Keyword stuffing as unethical and it doesn't help to boost the rank of a website. More advanced algorithms are being used to filter those of the meta tags which are irrelevant or excessively out of context in a website.

3 0
3 years ago
Assume that minutes is an int variable whose value is 0 or positive. Write an expression whose value is "undercooked" or "soft-b
e-lub [12.9K]

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

     Scanner scan = new Scanner(System.in);

     System.out.println("Enter your minute:");

     int minute = scan.nextInt();

     

     switch(minute){

         case 0:

         case 1:

             System.out.println("undercooked");

             break;

         case 2:

         case 3:

         case 4:

             System.out.println("soft-boiled");

             break;

         case 5:

         case 6:

         case 7:

             System.out.println("medium-boiled");

             break;

         case 8:

         case 9:

         case 10:

         case 11:

             System.out.println("hard-boiled");

             break;

         case 12:

             System.out.println("overcooked");

             break;

         default:

             if(minute > 12){

               System.out.println("overcooked");

             } else if (minute < 0){

                 System.out.println("Enter a valid minute.");

             }            

     }

   }

}

Explanation:

The first line is the import statement, which import the Scanner class for receiving user input. The next line is the class declaration which is named Solution.

The Scanner object is declared and assigned as scan. Then a prompt is displayed to the user asking the user to enter the minute. The user input is stored as minute.

Switch statement is use to categorize the user input. If the user enter 0-1, an output of undercooked is displayed. If the user enter 2-4, an output of soft-boiled is displayed. If the user enter 5-7, an output of medium-boiled is displayed. If the user enter 12 or any number above 12, an output of overcooked is displayed. Again, the user enter a number less than zero, an error message is displayed telling the user to enter a valid number.

4 0
2 years ago
Other questions:
  • If robots can work 24 hours a day, 365 days of the year,how many hours and days can humans work.
    12·2 answers
  • Which of these symbols is a special character that is accessible only from the Symbol dialog box? A. © B. + C. é D.
    13·2 answers
  • Sara has a habit of stealing money from her brother Charlie. When he found out, Charlie rebuked Sara in the presence of his frie
    11·1 answer
  • A technician is talking to end users about the specifications for an upgraded application server. The users of the application r
    11·1 answer
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • Differentiated instruction is designed to educate children through ________ techniques in order to ensure every student is being
    13·1 answer
  • Which statement best describes antivirus software?
    13·1 answer
  • I think my knee....
    14·1 answer
  • drag each type of document to the correct location on the table. Drag each document to its respective category
    7·1 answer
  • A(n) ____ is a live internet presentation that supports interactive communications between the presenter and the audience.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!