Question

I am running issues with these problems in MATHEMATICA software Coding class. I have previously posted the same material but have been getting answers in c++,Java, etc... I thank the great minds on here but, I am ONLY FOCUSED WITH THE MATHEMATICA program. I wanted to compare my work to confirm my progress. So please only answers in Mathematica language. thank u

a. Using a while loop, prompt the user for to input 5 numbers (the input numbers should be 1, 5, 9, 12, 16). The program should sum ONLY numbers that are divisible by 3 b.This program should request numbers, (with -1 to quit). It should ask the user whether they want to add or multiply the numbers. Must use a for add and m for multiply. Complete the operation. The numbers you should enter to be added are 3,2 and 8. To be multiplied 2, 3, 5

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

a.

#include <iostream>
using namespace std;
int main() {
int i=0,n,sum=0;
while(i<5){
cin>>n;
if(n%3==0){
sum+=n;
}
  
}
cout<<sum;
}

b.


#include <iostream>
using namespace std;
int main() {
int a[100],i=0,sum=0,product=1;
cout<<"Enter nos.";
cin>>a[i];
i++;
while(a[i-1]!=-1){
cin>>a[i];
i++;
}
char choice;
cout<<"Enter 'a' for addition and 'm' for multiplication: ";
cin>>choice;
  
i-=2;
if(choice=='a'){
for(int j=0;j<=i;j++){
sum+=a[j];
}
cout<<sum;
}
  
else if(choice=='m'){
for(int j=0;j<=i;j++){
product*=a[j];
}
cout<<product;
}
  
  
}

Add a comment
Know the answer?
Add Answer to:
I am running issues with these problems in MATHEMATICA software Coding class. I have previously posted...
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
  • c++ class, coding using code blocker MinilabLoopLogic The program: You are to write a program called...

    c++ class, coding using code blocker MinilabLoopLogic The program: You are to write a program called MinilabLoopLogic which does the following Asks the user to enter 2 integers (can be one prompt or two) Gets and stores the ints Explains that the program will generate all integers that are between the numbers and are divisible by a third integer . e Asks the user for the number they should be divisible by Gets and stores that int Since 0 will...

  • I am having trouble figuring out what should go in the place of "number" to make...

    I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...

  • So I am having probelms with figuring out how to do this program the part in...

    So I am having probelms with figuring out how to do this program the part in bold is the part I dont know how to do. This is in JAVA. What I have so far is shown below the question, this is right upto what I have to do next. Choose Your Operation Write a program that uses a WidgetViewer object to do the following: Generate two random integers between 1 and 9 (inclusive). Name one of them x, the...

  • I am writing a Java program. My program would ask two questions: (1) 1+1=? (2) 2+1...

    I am writing a Java program. My program would ask two questions: (1) 1+1=? (2) 2+1 =? Show one question at a time on the console. The program allows users to input answers via a command-line (no GUI). Give users five seconds to answer each question. The next question would show ONLY when the user answers the question correctly OR when the time is up. Once users answer the question correctly within the given time, the next question needs to...

  • I am required to use the try - catch block to validate the input as the...

    I am required to use the try - catch block to validate the input as the test data uses a word "Thirty" and not numbers. The program needs to validate that input, throw an exception and then display the error message. If I don't use the try - catch method I end up with program crashing. My issue is that I can't get the try - catch portion to work. Can you please help? I have attached what I have...

  • Could I get some help with the following Task? The program should be implemented in JavaScript and running on Firefox, a web browser independent to operating systems. The client has specified the foll...

    Could I get some help with the following Task? The program should be implemented in JavaScript and running on Firefox, a web browser independent to operating systems. The client has specified the following requirements for the functionality of the program: 1. The program should be running without errors throughout two Phases: Information Gathering and Information Presenting. 2. Information Gathering is to gather the information such as state/territory name, the population and population change over previous year for calculation of APG;...

  • You have been developing a Fraction class for Teacher’s Pet Software that contains several fields and...

    You have been developing a Fraction class for Teacher’s Pet Software that contains several fields and functions. a. Add four arithmetic operators, +, -, *, and /. Remember that to add or subtract two Fractions, you first must convert them to Fractions with a common denominator. You multiply two Fractions by multiplying the numerators and multiplying the denominators. You divide two Fractions by inverting the second Fraction, then multiplying. After any arithmetic operation, be sure the Fraction is in proper...

  • I need help with a project, I’ve seen many answers in C++, but i need it to be in swift, thank you!

    I need help with a project, I’ve seen many answers in C++, but i need it to be in swift, thank you! Write a program that asks the user to enter a date (e.g. July 4, 2008) and will return the day of the week that corresponds to that date. Your program should take the input in numeric form, thus the input prompt should be as follows: Please enter a date below: Enter month (1-12): Enter day (1-31) Enter year...

  • Hi, this is an intro to C Programming Class. Please do not use arrays, functions, math.h,...

    Hi, this is an intro to C Programming Class. Please do not use arrays, functions, math.h, or struct to store any data except to declare strings char strVar[20]. Furthermore, can you please do a good check to make sure the final program does not have any problems because when I copy and paste them the app I use says there are some problems and it won't run the program. So if you can double check to make sure that everything...

  • [PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a...

    [PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a human using text. Your program should involve asking the user questions and having the computer respond in a reasonably intelligent fashion based on those answers. For example, here is a sample chat: ChatBot: Welcome, I am Chatbot . What is your name? User: My name is Abby . ChatBot: Hello Abby. How old are you? User: 22. <---- Input ChatBot: That is older than...

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