Question

Multi part question c++ and yes I'm going to rate you up thank youu! Part A...

Multi part question c++ and yes I'm going to rate you up thank youu!

Part A

Ask the user to input a string.

Then sort the string in reverse lexicographic order and print it out.

This would be done using the integer values of the characters (ASCII table).

Use any one of the sorting methods.

For example:

if the user enters "zeta" sorting it in reverse lexicographic order would give "ztea".

if the user enters "ZETA" it would give "ZTEA".

Part B

Define a struct for a Circle with a radius, circumference, area.

Then define an array with 10 Circles.

Input the radius for each circle from the user (and also set its circumference, area).

Then output the area of the largest circle in the array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\color{blue}\underline{A:}

#include <string>
#include <iostream>
using namespace std;

int main() {
    string s;
    cout << "Enter a string: ";
    cin >> s;

    char ch;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < s.size()-1; ++j) {
            if (s[j] < s[j+1]) {
                ch = s[j];
                s[j] = s[j+1];
                s[j+1] = ch;
            }
        }
    }

    cout << s << endl;
    return 0;
}

\color{blue}\underline{B:}

#include <iostream>
using namespace std;

#define PI 3.14159

struct Circle {
    double radius;
    double area;
    double perimeter;
};

int main() {
    Circle circles[10];
    for (int i = 0; i < 10; ++i) {
        cout << "Enter radius of circle " << i+1 << ": ";
        cin >> circles[i].radius;
        circles[i].area = PI * circles[i].radius * circles[i].radius;
        circles[i].perimeter = 2 * PI * circles[i].radius;
    }

    Circle largest = circles[0];
    for (int i = 0; i < 10; ++i) {
        if (circles[i].area > largest.area) {
            largest = circles[i];
        }
    }
    
    cout << "Circle with largest area is of radius " << largest.radius << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Multi part question c++ and yes I'm going to rate you up thank youu! Part A...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • HI CAN YOU PLEASE PROGRAM THIS ASSIGNMENT USING C++ Ask the user to input a string. Then sort the string in reverse lex...

    HI CAN YOU PLEASE PROGRAM THIS ASSIGNMENT USING C++ Ask the user to input a string. Then sort the string in reverse lexicographic order and print it out. Reverse lexicographic means reverse alphabetic, e.g. zyxwvuts...edcba. This would be done using the integer values of the characters (ASCIl table). Use any one of the sorting methods we saw in class. For example: if the user enters "zeta" sorting it in reverse lexicographic order would give "ztea. if the user enters "ZETA"...

  • Multi Part question for c++ thank you and yes I'm going to rate you up thanks...

    Multi Part question for c++ thank you and yes I'm going to rate you up thanks ^^ Part A Question #1 Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string. Question #2 If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters. Hint: For comparing strings you can...

  • Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h,...

    Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h, P1.cpp The user enters 3 floating-pointer numbers which correspond to 3 radi. Store these numbers in an array. Then, define and prototype a function void area and cireffloat* area, float circumference, float array) which takes as input the array of circumferences of circles with the input radii. Think about why we need to pass pointers for both the area and the circumference variables. radii...

  • This is for C++ Write a program that reads in a sequence of characters entered by...

    This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...

  • Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the...

    Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the original high score program,: Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look exactly like this: Enter the name for score #1: Suzy Enter the score for...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • In C++ please. Thank you!! #include <iostream> #include <cstring> // print an array backwards, where 'first'...

    In C++ please. Thank you!! #include <iostream> #include <cstring> // print an array backwards, where 'first' is the first index // of the array, and 'last' is the last index void writeArrayBackward(const char anArray[], int first, int last) { int i = 0; for (i = last; i >= first; i--) { std::cout << anArray[i]; } std::cout << std::endl; } // test driver int main() { const char *s = "abc123"; writeArrayBackward(s, 0, strlen(s) - 1); } // Using the...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • Have you ever wanted to predict the future? Well the Magic Eight Ball does just that....

    Have you ever wanted to predict the future? Well the Magic Eight Ball does just that. The original game was a softball sized “8-ball”. You would ask a question, shake it up and look at the result. There are 20 responses…10 positive, 5 negative, and 5 are vague. For this project, we want to recreate this, but give the ability to read in a set of responses, and add additional responses, and print out all of the responses in alphabetical...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT