+ 19
How to solve the C# project multiple of 3
How to Solve Multiple of 3 C# project Problem: You are an elementary school teacher and explaining multiplication to students. You are going to use multiplication by 3 as your example. The program you are given takes N number as input. Write a program to output all numbers from 1 to N, replacing all numbers that Multiples of 3 by "*" Sample Input 7 Sample Output 12*45*7 Q: Is it asking me to list the multiples of 3 from 1 to 7? Also, How the F*** can 7 turn into 12*45*7? They need to explain what they want.
66 Answers
- 12
Abdul Qayom Silab🇦🇫 I just completed this assignment.
you have output the numbers in a line. you need to convert every multiple of 3 into *
it's not asking you to print 1 to 7 digits. you just have print 1 to N(where n is the user inputting any number)
+ 65
this is for everyone who is confused about how in the sample problem its input is 7 and the output includes 12 and 45 (which is obviously not between 1-7). In your program, it will not include the spaces in between the numbers. So, it isn't printing 12 and 45. It's printing 1, 2, 4, 5, 7 as numbers that are not multiples of 3 from 1-7. replacing the multiples of 3 from 1-7 with * (which are 3 and 6). That makes the output 12*45*7.
+ 38
using System;
using System.Collections.Generic;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int number = Convert.ToInt32(Console.ReadLine());
//your code goes here
for(int i=1; i<=number; i++)
{
if(i % 3==0)
{
Console.WriteLine("*");
}
else
{
Console.WriteLine(i);
}
}
}
}
}
+ 19
int number = Convert.ToInt32(Console.ReadLine());
for (int i=1;i<=number;i++)
if (i%3==0)
{Console.WriteLine("*"); }
else
{ Console.WriteLine(i);}
+ 16
Can someone tell me where the 12 and 45 are coming from
+ 14
i feel like this challenge is way out of line for the level of knowledge gained so far for a person new to coding.
as someone new to this stuff, ive been working through this course, and up until this point, ive been able to figure out pretty much everything under my own steam.
this challenge however, id have never in a hundred years been able to figure out without the use of a google search.
the question is badly phrased, and even after seeing the solution, its still breaking my brain to figure it out.
+ 13
(for i = 1; i <= number; i++)
if (i%3 == 0)
Print "*"
else print i;
Note: this is just the pseudo code not the real program, hope it helps
+ 5
Dude is really confusing
12 is twelve its 1 and 2 putting together, so it's using Write instead of WriteLine...
So its 1 2 * 4 5 * 7
+ 4
using System;
using System.Collections.Generic;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int number = Convert.ToInt32(Console.ReadLine());
for(int i=1;i<=number;i++){
Console.Write((i%3==0)?"*":Convert.ToString(i));
}
}
}
}
+ 3
using System;
using System.Collections.Generic;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int number = Convert.ToInt32(Console.ReadLine());
//your code goes here
for(int i=1; i<=number; i++)
{
if(i % 3==0)
{
Console.WriteLine("*");
}
else
{
Console.WriteLine(i);
}
}
}
}
}
Urraaaaaa!!!!!
+ 3
Can also use while loop
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int number = Convert.ToInt32(Console.ReadLine());
//your code goes here
int count = 0;
while (count < number)
{
count++;
if (count % 3 == 0)
{
Console.Write("*");
}
else
{
Console.Write(count);
}
}
}
}
}
+ 3
use Console.Write();
instead of :
Console.WriteLine();
in order to align the output in one line ...
Good Luck .
//your code goes here
for (int i = 1; i <= number; i++)
{
if (i % 3 == 0)
{
Console.Write("*");
}
else
{
Console.Write(i);
}
}
+ 2
int i;
Console.WriteLine(“Enter a number=“);
int number = Convert.ToInt32(Console.ReadLine());
for(i=1;i<=number;i++){
if(i%3==0)
Console.Write(“*”);
else
Console.Write(i);
}
+ 2
Don't use Console.WriteLine since you want it on the same line instead use Console.Write
int number = Convert.ToInt32(Console.ReadLine());
for(int x = 1; x <= number; x++)
if (x % 3 == 0)
{
Console.Write("*");
}
else
{
Console.Write(x);
}
+ 1
startNumber++ in the loop, <= condition. also handle what you should print if the condition is not true. use Write() to print in a single line without going to next line after printing MrDevEzeoke
+ 1
it was cofusing that SL didn't clarified the type of output data. Outputs can be ints and * char line by line in console, no need to convert all in one line string.
+ 1
Ugh. This is so confusing when you look at it at face value. Count from 1 to the Input number. Maybe write it down on a notebook. Then compare the numbers you
wrote to what the output is asking. Look for similarities.
It's obnoxiously simple of an answer.
If you still don't get it, pretend the asterisk is a censor.
+ 1
The program should look like this
//taking N input from user
int number = Convert.ToInt32(Console.ReadLine());
//print out 1 - N using FOR loop
for(int i = 1; i < number; i++){
// use IF statement to find numbers that can divide by 3. then print out "*"
if(i % 3 == 0){
Console.Write("*"); //make sure using WRITE not WRITELINE because writeline will print in a new line each time program iterates.
}
// use ELSE to print the rest of the other numbers
else{
Console.Write(i);
}
}
+ 1
int number = Convert.ToInt32(Console.ReadLine());
//your code goes here
int i = 1;
while (i <= number)
{
if(i%3==0)
{
Console.Write("*");
}
else
{
Console.Write(i);
}
i++;
}
+ 1
It took me a good 20 minutes of thinking, writing down, and consulting with my roommate about how to answer this problem. I was really confused about the 12 and 45, but then we realized it was 1, 2, *, 4, 5, *, 7. Something that would make this problem a lot more understandable would be adding some sort of delimiter (a new line, a comma, a space, etc.) between the numbers. Please change this problem explanation and example, as it is very confusing. And, reading the comments, I am not the only one that was confused.