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
IceJOKER [234]
3 years ago
12

Given a string variable s that has already been declared, write some code that repeatedly reads a value from standard input into

s until at last a "Y" or "y"or "N" or "n" has been entered.
Computers and Technology
1 answer:
valina [46]3 years ago
4 0

Answer:

The code to this question can be given as:

Code:

while ((s!="Y" && s!="y" && s!="N" && s!="n"))  //loop for check condition

{

cin >> s;  //insert value

}

Explanation:

The description of the following code:

  • In this code, we use a string variable s that has been to define in question.
  • In code, we use a while loop. It is an entry control loop in loop we check variable s value is not equal to "y", "Y", "n" and "N".  
  • In the loop we use AND operator that checks all value together. If this is true So, we insert value-form user input in string variable that is "s".
You might be interested in
6.10.1: Modify a C string parameter. Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley.
Andrej [43]

Answer:

#include <iostream>

#include <cstring>

using namespace std;

void replacePeriod(char* phrase) {

int i = 0;

while(*(phrase + i) != '\0')

{

if(*(phrase + i) == '.')

*(phrase + i) = '!';

i++;

}

}

int main() {

const int STRING_SIZE = 50;

char sentence[STRING_SIZE];

strcpy(sentence, "Hello. I'm Miley. Nice to meet you.");

replacePeriod(sentence);

cout << "Updated sentence: " << endl;

cout << sentence << endl;

return 0;

}

Explanation:

  • Create a function called replacePeriod that takes a pointer of type char as a parameter.
  • Loop through the end of phrase, check if phrase has a period and then replace it with a sign of exclamation.
  • Inside the main function, define the sentence and pass it as an argument to the replacePeriod function.
  • Finally display the updated sentence.
6 0
3 years ago
Please help I have errors codes and don’t know that they are.<br> Please help thank You.
gizmo_the_mogwai [7]
Refresh, power off and repeat
4 0
2 years ago
Read 2 more answers
Which of the following represents something businesses do to keep the integrity and security of their company data?
iren [92.7K]
I’m not sure but if I wouod have to answer it would be 2 or 3
6 0
2 years ago
Design a class named Complex for representing complex numbers and the methods add, subtract, multiply, divide, abs for performin
Tanzania [10]

Answer:

Explanation:

The following code is written in Java, it creates the entire complex class as requested so that it works with the main method that has been provided in the question without having to change anything in the main method. Proof of output can be seen in the attached picture below

import java.util.Scanner;

class Test implements Cloneable{

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       System.out.print("Enter the first complex number: ");

       double a = input.nextDouble();

       double b = input.nextDouble();

       Complex c1 = new Complex(a, b);

       System.out.print("Enter the second complex number: ");

       double c = input.nextDouble();

       double d = input.nextDouble();

       Complex c2 = new Complex(c, d);

       System.out.println("(" + c1 + ")" + " + " + "(" + c2 + ")" + " = " + c1.add(c2));

       System.out.println("(" + c1 + ")" + " - " + "(" + c2 + ")" + " = " + c1.subtract(c2));

       System.out.println("(" + c1 + ")" + " * " + "(" + c2 + ")" + " = " + c1.multiply(c2));

       System.out.println("(" + c1 + ")" + " / " + "(" + c2 + ")" + " = " + c1.divide(c2));

       System.out.println("|" + c1 + "| = " + c1.abs());

       Complex c3 = c1;

       System.out.println(c1 == c3);

       System.out.println(c3.getRealPart());

       System.out.println(c3.getImaginaryPart());

   }

}

class Complex implements Cloneable {

   public interface Cloneable { }

   private double realPart;

   public double getRealPart() {

       return realPart;

   }

   public void setReal(double real) {

       this.realPart = real;

   }

   private double imaginaryPart;

   public double getImaginaryPart() {

       return imaginaryPart;

   }

   public void setImaginary(double imaginary) {

       this.imaginaryPart = imaginary;

   }

   public Complex(double a, double b) {

       realPart = a;

       imaginaryPart = b;

   }

   public Complex(double a) {

       realPart = a;

       imaginaryPart = 0;

   }

   public Complex() { }

   public Complex add(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getImaginaryPart();

       double imaginary2 = comp2.getImaginaryPart();

       return new Complex(real1 + real2, imaginary1 + imaginary2);

   }

   public Complex abs() {

       double real1 = Math.abs(this.getRealPart());

       double imaginary1 = Math.abs(this.getImaginaryPart());

       return new Complex(real1, imaginary1);

   }

   public Complex subtract(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 - real2, imaginary1 - imaginary2);

   }

   public Complex multiply(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 * real2, imaginary1 * imaginary2);

   }

   public Complex divide(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 / real2, imaginary1 / imaginary2);

   }

   public String toString() {

       String result;

       result = realPart + " + " + imaginaryPart + "i";

       return result;

   }

}

3 0
2 years ago
A Task can be created in Outlook 2016 by clicking on the Tasks navigation item, or by
Ymorist [56]

Answer:flagging an email

Explanation:

I got it right!

7 0
3 years ago
Read 2 more answers
Other questions:
  • Software that instructs the computer how to run applications and controls the display/keyboard is know as the
    8·1 answer
  • __________ is a collection of formatting options—such as a frame, a rounded shape, and a shadow—that changes a picture’s overall
    5·1 answer
  • A(n) __ is a list of main points and sub-points of a topic to include in a presentation
    14·2 answers
  • What will be the output of the following code? &lt;?php $foo = 'Bob'; $bar = $foo; $bar = "My name is $bar"; print $bar; print $
    8·2 answers
  • A nonprofit organization uses a contact management database to track donations, amounts donated, and all correspondence and phon
    11·1 answer
  • Describe the different non-printing characters,​
    11·1 answer
  • How many jobs can you get without a college degree
    13·2 answers
  • Which is the correct option?
    6·1 answer
  • One limitation of high-level programming languages is
    10·1 answer
  • What does the asterisk (*) after select tell the database to do in this query?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!