In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
From Europython 2016
Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique.
The audience will have some familiarity with unit testing and may have tried mocking before, but some introduction will be provided for those who havenât. We will look at some features and techniques of Pythonâs unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively.
Video: https://www.youtube.com/watch?v=Ahnw72diels
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
From Europython 2016
Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique.
The audience will have some familiarity with unit testing and may have tried mocking before, but some introduction will be provided for those who havenât. We will look at some features and techniques of Pythonâs unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively.
Video: https://www.youtube.com/watch?v=Ahnw72diels
Exceptions Triggers function in SQL by Vasant Bhabad
Â
Similar to Star pattern programs in java Print Star pattern in java and print triangle of stars in java, print star triangle of java, * pattern in java
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfanjanacottonmills
Â
MagicSquareTest.java
import java.util.Scanner;
public class MagicSquareTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter Number of rows:\");
int rows = scan.nextInt();
System.out.println(\"Enter Nummber of columns:\");
int cols = scan.nextInt();
int a[][] = new int[rows][cols];
System.out.println(\"Enter matrix elements;\");
for(int i=0; i
Solution
MagicSquareTest.java
import java.util.Scanner;
public class MagicSquareTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter Number of rows:\");
int rows = scan.nextInt();
System.out.println(\"Enter Nummber of columns:\");
int cols = scan.nextInt();
int a[][] = new int[rows][cols];
System.out.println(\"Enter matrix elements;\");
for(int i=0; i.
import java.util.Scanner;public class ArrayOperation { Â Â inp.pdfangelsfashion1
Â
import java.util.Scanner;
public class ArrayOperation {
/* input method implementation */
public static double[] input() {
Scanner sc = new Scanner(System.in);
System.out.println(\"Please enter the size of array\");
int n = sc.nextInt();
double number[] = new double[n];
/* Inserting element to array */
for (int i = 0; i < n; i++) {
number[i] = sc.nextDouble();
}
/* printing array by calling print method */
print(number);
return number;
}
public static void print(double number[]) {
/* Printing array */
for (int i = 0; i < number.length; i++) {
System.out.print(number[i] + \" \");
}
System.out.println();
}
/* sqrtnumber method implemantation */
public static void sqrtNumber(double number[]) {
/* Printing sqrt of numbers */
System.out.println(\"Square root of Number of an array\");
for (int i = 0; i < number.length; i++) {
double num = Math.sqrt(number[i]);
System.out.println(num);
}
}
public static void main(String args[]) {
/* Calling initaize array */
double number[] = input();
/* calling sqrtnumber */
sqrtNumber(number);
}
}
/***********output*****************/
Please enter the size of array
5
5
6
7
8
14
5.0 6.0 7.0 8.0 14.0
Square root of Number of an array
2.23606797749979
2.449489742783178
2.6457513110645907
2.8284271247461903
3.7416573867739413
Solution
import java.util.Scanner;
public class ArrayOperation {
/* input method implementation */
public static double[] input() {
Scanner sc = new Scanner(System.in);
System.out.println(\"Please enter the size of array\");
int n = sc.nextInt();
double number[] = new double[n];
/* Inserting element to array */
for (int i = 0; i < n; i++) {
number[i] = sc.nextDouble();
}
/* printing array by calling print method */
print(number);
return number;
}
public static void print(double number[]) {
/* Printing array */
for (int i = 0; i < number.length; i++) {
System.out.print(number[i] + \" \");
}
System.out.println();
}
/* sqrtnumber method implemantation */
public static void sqrtNumber(double number[]) {
/* Printing sqrt of numbers */
System.out.println(\"Square root of Number of an array\");
for (int i = 0; i < number.length; i++) {
double num = Math.sqrt(number[i]);
System.out.println(num);
}
}
public static void main(String args[]) {
/* Calling initaize array */
double number[] = input();
/* calling sqrtnumber */
sqrtNumber(number);
}
}
/***********output*****************/
Please enter the size of array
5
5
6
7
8
14
5.0 6.0 7.0 8.0 14.0
Square root of Number of an array
2.23606797749979
2.449489742783178
2.6457513110645907
2.8284271247461903
3.7416573867739413.
Q3 GIVEN THE TREND EQUATION NO OF STUDENTS-3000+200 YEAR BASE: 2003-0
1.INTERPRET EQUATION RESULTS 2.FORECAST FOR 2020 3.WHEN WILL THE NO OF
STUDENTS REACH 6000
Solution
x no of years from 2003 y no of students y = 3000+200x 1) The regression
equation has a positive slope of 200 y intercept is 3000 i.e. no of students in the year 2000
Thus for every year 200 students increase 2) For 2020, x = 17, y = 3000+200(17) = 6400
3) When y =6000, 6000 = 3000+200x or x = 15 Hence in year 2018 students reach 6000
B Regression C D. All the above.
import java.util.;public class Program{public static void.pdfoptokunal1
Â
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String x=\"X\";
int amount;
System.out.println(\"Enter amount\");
amount=input.nextInt();
System.out.println(\"Amount is: \"+amount);
for(int i=1; i<=amount; i++)
{
System.out.println(x);
for(int j=1; j<=i; j++)
{
System.out.print(x);
}
}
}
}
Why does It print out the last set of X\'s twice? I am doing basic Java so please try to explain
using the most basic codes.
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String x=\"X\";
int amount;
System.out.println(\"Enter amount\");
amount=input.nextInt();
System.out.println(\"Amount is: \"+amount);
for(int i=1; i<=amount; i++)
{
System.out.println(x);
for(int j=1; j<=i; j++)
{
System.out.print(x);
}
}
}
}
Why does It print out the last set of X\'s twice? I am doing basic Java so please try to explain
using the most basic codes.
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String x=\"X\";
int amount;
System.out.println(\"Enter amount\");
amount=input.nextInt();
System.out.println(\"Amount is: \"+amount);
for(int i=1; i<=amount; i++)
{
System.out.println(x);
for(int j=1; j<=i; j++)
{
System.out.print(x);
}
}
}
}
Why does It print out the last set of X\'s twice? I am doing basic Java so please try to explain
using the most basic codes.
Solution
Hi,
I have modified the code. it is working as expected now. Highlighted the code changes below.
Issue here is with you have written this statement twice System.out.println(x); which causes the
issue.
Program.java
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String x=\"X\";
int amount;
System.out.println(\"Enter amount\");
amount=input.nextInt();
System.out.println(\"Amount is: \"+amount);
for(int i=1; i<=amount; i++)
{
System.out.println();
for(int j=1; j<=i; j++)
{
System.out.print(x);
}
}
}
}
Output:
Enter amount
10
Amount is: 10
X
XX
XXX
XXXX
XXXXX
XXXXXX
XXXXXXX
XXXXXXXX
XXXXXXXXX
XXXXXXXXXX.
WAP to create equivalent of a four function calculator. The program requires the user to enter two numbers and an operator. It then carries out the specified arithmetic operation: addition, subtraction, multiplication and division of two numbers.(using nested if statement)
Similar to Star pattern programs in java Print Star pattern in java and print triangle of stars in java, print star triangle of java, * pattern in java (20)
What website can I sell pi coins securely.DOT TECH
Â
Currently there are no website or exchange that allow buying or selling of pi coins..
But you can still easily sell pi coins, by reselling it to exchanges/crypto whales interested in holding thousands of pi coins before the mainnet launch.
Who is a pi merchant?
A pi merchant is someone who buys pi coins from miners and resell to these crypto whales and holders of pi..
This is because pi network is not doing any pre-sale. The only way exchanges can get pi is by buying from miners and pi merchants stands in between the miners and the exchanges.
How can I sell my pi coins?
Selling pi coins is really easy, but first you need to migrate to mainnet wallet before you can do that. I will leave the telegram contact of my personal pi merchant to trade with.
Tele-gram.
@Pi_vendor_247
Empowering the Unbanked: The Vital Role of NBFCs in Promoting Financial Inclu...Vighnesh Shashtri
Â
In India, financial inclusion remains a critical challenge, with a significant portion of the population still unbanked. Non-Banking Financial Companies (NBFCs) have emerged as key players in bridging this gap by providing financial services to those often overlooked by traditional banking institutions. This article delves into how NBFCs are fostering financial inclusion and empowering the unbanked.
Falcon stands out as a top-tier P2P Invoice Discounting platform in India, bridging esteemed blue-chip companies and eager investors. Our goal is to transform the investment landscape in India by establishing a comprehensive destination for borrowers and investors with diverse profiles and needs, all while minimizing risk. What sets Falcon apart is the elimination of intermediaries such as commercial banks and depository institutions, allowing investors to enjoy higher yields.
how can i use my minded pi coins I need some funds.DOT TECH
Â
If you are interested in selling your pi coins, i have a verified pi merchant, who buys pi coins and resell them to exchanges looking forward to hold till mainnet launch.
Because the core team has announced that pi network will not be doing any pre-sale. The only way exchanges like huobi, bitmart and hotbit can get pi is by buying from miners.
Now a merchant stands in between these exchanges and the miners. As a link to make transactions smooth. Because right now in the enclosed mainnet you can't sell pi coins your self. You need the help of a merchant,
i will leave the telegram contact of my personal pi merchant below. đ I and my friends has traded more than 3000pi coins with him successfully.
@Pi_vendor_247
how to sell pi coins at high rate quickly.DOT TECH
Â
Where can I sell my pi coins at a high rate.
Pi is not launched yet on any exchange. But one can easily sell his or her pi coins to investors who want to hold pi till mainnet launch.
This means crypto whales want to hold pi. And you can get a good rate for selling pi to them. I will leave the telegram contact of my personal pi vendor below.
A vendor is someone who buys from a miner and resell it to a holder or crypto whale.
Here is the telegram contact of my vendor:
@Pi_vendor_247
how can I sell pi coins after successfully completing KYCDOT TECH
Â
Pi coins is not launched yet in any exchange đą this means it's not swappable, the current pi displaying on coin market cap is the iou version of pi. And you can learn all about that on my previous post.
RIGHT NOW THE ONLY WAYÂ you can sell pi coins is through verified pi merchants. A pi merchant is someone who buys pi coins and resell them to exchanges and crypto whales. Looking forward to hold massive quantities of pi coins before the mainnet launch.
This is because pi network is not doing any pre-sale or ico offerings, the only way to get my coins is from buying from miners. So a merchant facilitates the transactions between the miners and these exchanges holding pi.
I and my friends has sold more than 6000 pi coins successfully with this method. I will be happy to share the contact of my personal pi merchant. The one i trade with, if you have your own merchant you can trade with them. For those who are new.
Message: @Pi_vendor_247 on telegram.
I wouldn't advise you selling all percentage of the pi coins. Leave at least a before so its a win win during open mainnet. Have a nice day pioneers âĽď¸
#kyc #mainnet #picoins #pi #sellpi #piwallet
#pinetwork
Currently pi network is not tradable on binance or any other exchange because we are still in the enclosed mainnet.
Right now the only way to sell pi coins is by trading with a verified merchant.
What is a pi merchant?
A pi merchant is someone verified by pi network team and allowed to barter pi coins for goods and services.
Since pi network is not doing any pre-sale The only way exchanges like binance/huobi or crypto whales can get pi is by buying from miners. And a merchant stands in between the exchanges and the miners.
I will leave the telegram contact of my personal pi merchant. I and my friends has traded more than 6000pi coins successfully
Tele-gram
@Pi_vendor_247
Exploring Abhay Bhutadaâs Views After Poonawalla Fincorpâs Collaboration With...beulahfernandes8
Â
The financial landscape in India has witnessed a significant development with the recent collaboration between Poonawalla Fincorp and IndusInd Bank.
The launch of the co-branded credit card, the IndusInd Bank Poonawalla Fincorp eLITE RuPay Platinum Credit Card, marks a major milestone for both entities.
This strategic move aims to redefine and elevate the banking experience for customers.
how to sell pi coins effectively (from 50 - 100k pi)DOT TECH
Â
Anywhere in the world, including Africa, America, and Europe, you can sell Pi Network Coins online and receive cash through online payment options.
Pi has not yet been launched on any exchange because we are currently using the confined Mainnet. The planned launch date for Pi is June 28, 2026.
Reselling to investors who want to hold until the mainnet launch in 2026 is currently the sole way to sell.
Consequently, right now. All you need to do is select the right pi network provider.
Who is a pi merchant?
An individual who buys coins from miners on the pi network and resells them to investors hoping to hang onto them until the mainnet is launched is known as a pi merchant.
debuts.
I'll provide you the Telegram username
@Pi_vendor_247
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Cardnickysharmasucks
Â
The unveiling of the IndusInd Bank Poonawalla Fincorp eLITE RuPay Platinum Credit Card marks a notable milestone in the Indian financial landscape, showcasing a successful partnership between two leading institutions, Poonawalla Fincorp and IndusInd Bank. This co-branded credit card not only offers users a plethora of benefits but also reflects a commitment to innovation and adaptation. With a focus on providing value-driven and customer-centric solutions, this launch represents more than just a new productâit signifies a step towards redefining the banking experience for millions. Promising convenience, rewards, and a touch of luxury in everyday financial transactions, this collaboration aims to cater to the evolving needs of customers and set new standards in the industry.
What price will pi network be listed on exchangesDOT TECH
Â
The rate at which pi will be listed is practically unknown. But due to speculations surrounding it the predicted rate is tends to be from 30$ â 50$.
So if you are interested in selling your pi network coins at a high rate tho. Or you can't wait till the mainnet launch in 2026. You can easily trade your pi coins with a merchant.
A merchant is someone who buys pi coins from miners and resell them to Investors looking forward to hold massive quantities till mainnet launch.
I will leave the telegram contact of my personal pi vendor to trade with.
@Pi_vendor_247
Financial Assets: Debit vs Equity Securities.pptxWrito-Finance
Â
financial assets represent claim for future benefit or cash. Financial assets are formed by establishing contracts between participants. These financial assets are used for collection of huge amounts of money for business purposes.
Two major Types: Debt Securities and Equity Securities.
Debt Securities are Also known as fixed-income securities or instruments. The type of assets is formed by establishing contracts between investor and issuer of the asset.
⢠The first type of Debit securities is BONDS. Bonds are issued by corporations and government (both local and national government).
⢠The second important type of Debit security is NOTES. Apart from similarities associated with notes and bonds, notes have shorter term maturity.
⢠The 3rd important type of Debit security is TRESURY BILLS. These securities have short-term ranging from three months, six months, and one year. Issuer of such securities are governments.
⢠Above discussed debit securities are mostly issued by governments and corporations. CERTIFICATE OF DEPOSITS CDs are issued by Banks and Financial Institutions. Risk factor associated with CDs gets reduced when issued by reputable institutions or Banks.
Following are the risk attached with debt securities: Credit risk, interest rate risk and currency risk
There are no fixed maturity dates in such securities, and assetâs value is determined by companyâs performance. There are two major types of equity securities: common stock and preferred stock.
ď Common Stock: These are simple equity securities and bear no complexities which the preferred stock bears. Holders of such securities or instrument have the voting rights when it comes to select the companyâs board of director or the business decisions to be made.
ď Preferred Stock: Preferred stocks are sometime referred to as hybrid securities, because it contains elements of both debit security and equity security. Preferred stock confers ownership rights to security holder that is why it is equity instrument
<a href="https://www.writofinance.com/equity-securities-features-types-risk/" >Equity securities </a> as a whole is used for capital funding for companies. Companies have multiple expenses to cover. Potential growth of company is required in competitive market. So, these securities are used for capital generation, and then uses it for companyâs growth.
Concluding remarks
Both are employed in business. Businesses are often established through debit securities, then what is the need for equity securities. Companies have to cover multiple expenses and expansion of business. They can also use equity instruments for repayment of debits. So, there are multiple uses for securities. As an investor, you need tools for analysis. Investment decisions are made by carefully analyzing the market. For better analysis of the stock market, investors often employ financial analysis of companies.
Star pattern programs in java Print Star pattern in java and print triangle of stars in java, print star triangle of java, * pattern in java
1. 35 Star Pattern Programs In Java | Pattern Program
In this article, we will learn to print the different Star Pattern Programs in Java. This is one of the popular
Java pattern program interview question for fresher. The pattern program are the most recommended
programs to enhance the logical thinking and for the better understanding of flow control. Lets look into
the below possible Star Pattern Programs in Java which might help for both the fr
Star Pattern Programs In Java
Star Pattern Programs In Java 1
Star Pattern Programs In Java 3
Star Pattern Programs In Java
Pattern 1:
package com.javainterviewpoint;
import java.util.Scanner;
public class Pattern1
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
2. // Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
***
****
*****
Pattern 2:
import java.util.Scanner;
public class Pattern2
{
3. public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in decreasing order
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=i; k++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
4. Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
***
****
*****
Pattern 3:
import java.util.Scanner;
public class Pattern3
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print star in decreasing order
5. for (int k=rows; k>=i; k--)
{
System.out.print("*");
}
// Print space in increasing order
for (int j=1; j<i; j++)
{
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
****
***
**
*
Pattern 4:
import java.util.Scanner;
6. public class Pattern4
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in increasing order
for (int j=1; j<i; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k=rows; k>=i; k--)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
7. }
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
****
***
**
*
Pattern 5: [ Pyramid Star Pattern ]
import java.util.Scanner;
public class Pattern5
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
8. {
// Print space in decreasing order
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=(i * 2) -1; k++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
***
*****
*******
*********
Pattern 6:
9. import java.util.Scanner;
public class Pattern6
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=rows; i>=1; i--)
{
// Print star in decreasing order
for (int k=1; k<=(i * 2) -1; k++)
{
System.out.print("*");
}
System.out.println();
// Print space in increasing order
for (int j=rows; j>=i; j--)
{
System.out.print(" ");
}
10. }
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*********
*******
*****
***
*
Pattern 7: [Diamond Star Pattern ]
import java.util.Scanner;
public class Pattern7
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
11. int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in decreasing order
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=(i * 2) -1; k++)
{
System.out.print("*");
}
System.out.println();
}
for (int i=rows-1; i>=1; i--)
{
// Print space in increasing order
for (int j=rows-1; j>=i; j--)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k=1; k<=(i * 2) -1; k++)
{
System.out.print("*");
12. }
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
***
*****
*******
*********
*******
*****
***
*
Pattern 8:
import java.util.Scanner;
public class Pattern8
{
public static void main(String[] args)
13. {
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print("*");
}
System.out.println();
}
for (int i=1; i<=rows-1; i++)
{
// Print star in decreasing order
for (int j = rows-1; j >= i; j--)
{
System.out.print("*");
}
// Print space in increasing order
for (int k = 1; k < i; k++)
15. public class Pattern9
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
// Print space in decreasing order
for (int j = rows; j > i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k = 1; k <= i; k++)
{
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= rows-1; i++)
{
16. // Print space in increasing order
for (int j = 1; j <= i; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = rows-1; k >= i; k--)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
***
****
*****
****
***
**
*
17. Pattern 10:
package com.javainterviewpoint;
import java.util.Scanner;
public class Pattern10
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = rows-1; j>=i; j--)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = 1; k <= rows; k++)
{
System.out.print("*");
}
18. System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
*****
*****
*****
*****
Pattern 11:
import java.util.Scanner;
public class Pattern11
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
19. System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i-1; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = 1; k <= rows; k++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
*****
*****
20. *****
*****
Pattern 12:
import java.util.Scanner;
public class Pattern12
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = rows; i >= 1; i--)
{
for (int j = i; j >= 1; j--)
{
System.out.print("*");
}
System.out.println();
}
21. for (int i = 2; i <= rows; i++)
{
for (int j = i; j >= 1; j--)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
****
***
**
*
**
***
****
*****
Pattern 13:
22. import java.util.Scanner;
public class Pattern13
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
System.out.print("*");
}
System.out.println();
}
23. for (int i = rows-1; i >= 1; i--)
{
for (int j = 2; j <=i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
****
***
**
*
**
***
****
24. *****
Pattern 14:
import java.util.Scanner;
public class Pattern14
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
System.out.print("* ");
25. }
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
System.out.print("* ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
* * * * *
* * * *
* * *
* *
*
26. * *
* * *
* * * *
* * * * *
Pattern 15:
import java.util.Scanner;
public class Pattern15
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j=1; j<=i; j++)
{
if( j == 1 || j == i || i == rows)
28. // Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in decreasing order
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=i; k++)
{
if( k == 1 || k == i || i == rows)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
29. Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
* *
* *
*****
Pattern 17:
import java.util.Scanner;
public class Pattern17
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
30. for (int i=1; i<=rows; i++)
{
// Print star in decreasing order
for (int j=rows; j >=i; j--)
{
if( i == 1 || j == i || j == rows)
System.out.print("*");
else
System.out.print(" ");
}
// Print space in increasing order
for (int k=1; k<i; k++)
{
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
* *
* *
31. **
*
Pattern 18:
import java.util.Scanner;
public class Pattern18
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in increasing order
for (int j=1; j<i; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
32. for (int k=rows; k>=i; k--)
{
if( i == 1 || k == i || k == rows)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
* *
* *
**
*
Pattern 19:
import java.util.Scanner;
public class Pattern19
33. {
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in decreasing order
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=(i * 2) -1; k++)
{
if( k == 1 || k == (i * 2) -1 || i == rows)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
34. scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
* *
* *
* *
*********
Pattern 20:
import java.util.Scanner;
public class Pattern20
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
35. int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=rows; i>=1; i--)
{
// Print star in decreasing order
for (int j=1; j <=(i * 2) -1; j++)
{
if( j == 1 || j == (i * 2) -1 || i == rows)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
// Print space in increasing order
for (int k = rows; k >= i; k--)
{
System.out.print(" ");
}
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
36. ## Printing the pattern ##
*********
* *
* *
* *
*
Pattern 21:
import java.util.Scanner;
public class Pattern21
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
// Print space in decreasing order
for (int j=rows; j>i; j--)
37. {
System.out.print(" ");
}
// Print star in increasing order
for (int k=1; k<=(i * 2) -1; k++)
{
if( k == 1 || k == (i * 2) -1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for (int i=rows-1; i>=1; i--)
{
// Print space in increasing order
for (int j=rows-1; j>=i; j--)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k=1; k<=(i * 2) -1; k++)
{
if( k == 1 || k == (i * 2) -1 )
System.out.print("*");
else
System.out.print(" ");
}
39. {
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j=1; j<=i; j++)
{
if( j == 1 || j == i )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for (int i=1; i<=rows-1; i++)
{
// Print star in decreasing order
for (int j = rows-1; j >= i; j--)
{
if( j == rows-1 || j == i || i == rows)
40. System.out.print("*");
else
System.out.print(" ");
}
// Print space in increasing order
for (int k = 1; k < i; k++)
{
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
* *
* *
* *
* *
* *
**
*
41. Pattern 23:
import java.util.Scanner;
public class Pattern23
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
// Print space in decreasing order
for (int j = rows; j > i; j--)
{
System.out.print(" ");
}
// Print star in increasing order
for (int k = 1; k <= i; k++)
{
42. if( k == 1 || k == i )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for (int i = 1; i <= rows-1; i++)
{
// Print space in increasing order
for (int j = 1; j <= i; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = rows-1; k >= i; k--)
{
if( k == rows-1 || k == i )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
43. Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
* *
* *
* *
* *
* *
**
*
Pattern 24:
import java.util.Scanner;
public class Pattern24
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
44. System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = rows-1; j>=i; j--)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = 1; k <= rows; k++)
{
if( i == 1 || i == rows || k == 1 || k == rows )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
* *
* *
45. * *
*****
Pattern 25:
import java.util.Scanner;
public class Pattern25
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i-1; j++)
{
System.out.print(" ");
}
// Print star in decreasing order
for (int k = 1; k <= rows; k++)
46. {
if( i == 1 || i == rows || k == 1 || k == rows )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
* *
* *
* *
*****
Pattern 26:
import java.util.Scanner;
public class Pattern26
{
47. public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print("*");
}
for (int k = i*2; k <= rows*2-1; k++)
{
System.out.print(" ");
}
for (int l = 1; l <= i; l++)
{
System.out.print("*");
}
System.out.println();
}
48. for (int i=1; i<=rows-1; i++)
{
for (int j = rows-1; j >= i; j--)
{
System.out.print("*");
}
for (int k = 1; k <= i*2; k++)
{
System.out.print(" ");
}
for (int l = rows-1; l >= i; l--)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
* *
** **
*** ***
**** ****
49. **********
**** ****
*** ***
** **
* *
Pattern 27:
import java.util.Scanner;
public class Pattern27
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j = i; j <= rows; j++)
{
50. System.out.print("*");
}
for (int k = 1; k <= i*2-2; k++)
{
System.out.print(" ");
}
for (int l = i; l <= rows; l++)
{
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print("*");
}
for (int k = i*2-2; k < rows*2-2; k++)
{
System.out.print(" ");
}
for (int l = 1; l <= i; l++)
{
System.out.print("*");
}
System.out.println();
51. }
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********
Pattern 28:
import java.util.Scanner;
public class Pattern28
{
public static void main(String[] args)
{
52. // Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i=1; i<=rows; i++)
{
for (int j=rows; j>i; j--)
{
System.out.print(" ");
}
for (int k=1; k<=(i * 2) -1; k++)
{
if(k == 1 || k == i*2 -1 || k == 1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for (int i=rows-1; i>=1; i--)
{
for (int j=rows-1; j>=i; j--)
{
System.out.print(" ");
53. }
for (int k=1; k<=(i * 2) -1; k++)
{
if(k == 1 || k == i*2 -1 || k == 1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
* *
* *
* *
* *
* *
* *
* *
*
Pattern 29:
54. import java.util.Scanner;
public class Pattern29
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
if( i == 1 || k == i || k == rows)
System.out.print("* ");
else
55. System.out.print(" ");
}
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int k = i; k <= rows; k++)
{
if( i == 1 || k == i || k == rows)
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
* * * * *
56. * *
* *
* *
*
* *
* *
* *
* * * * *
Pattern 30:
import java.util.Scanner;
public class Pattern30
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
57. {
for (int j=1; j<=rows; j++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*****
*****
*****
*****
*****
Pattern 31:
import java.util.Scanner;
public class Pattern31
{
public static void main(String[] args)
58. {
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j=1; j<=rows; j++)
{
if(i ==1 || i == rows || j == 1 || j == rows )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
59. ## Print star pattern in java ##
*****
* *
* *
* *
*****
Pattern 32:
import java.util.Scanner;
public class Pattern32
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to in the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=(rows * 2 -1); i++)
{
for (int j=1; j<=rows; j++)
61. public class Pattern33
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to in the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=(rows * 2 -1); i++)
{
if( i == rows)
{
// Printing Horizontal Line of Stars
for (int j=1; j<=(rows * 2 -1); j++)
{
System.out.print("*");
}
}
else
{
// Printing space before Vertical Line of Stars
for(int k=1; k<= rows-1; k++)
{
63. public class Pattern34
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to in the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i = 1; i <= rows * 2 - 1; i++)
{
if (i == 1 || i == rows || i == rows * 2 - 1)
{
for (int j = 1; j <= rows; j++)
{
if (j == 1 || j == rows)
System.out.print(" ");
else
System.out.print("*");
}
}
else
{
for (int k = 1; k <= rows; k++)
64. {
if (k == 1 || k == rows)
System.out.print("*");
else
System.out.print(" ");
}
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to in the pattern
5
## Printing the pattern ##
***
* *
* *
* *
***
* *
* *
* *
***
Pattern 35:
65. import java.util.Scanner;
public class Pattern35
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to in the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for(int i=1; i<= rows; i++)
{
if(i%2 != 0)
{
for(int j=1; j<= rows/2+1; j++)
{
System.out.print("* ");
}
}
else
{
66. for(int j=1; j<= rows/2; j++)
{
System.out.print(" * ");
}
}
System.out.println("");
}
}
}
Output
Enter the number of rows needed to in the pattern
5
## Printing the pattern ##
* * *
* *
* * *
* *
* * *
Filed Under: Java, Java Interview
Tagged With: Diamond pattern, Half Diamond Pattern, Hollow Triangle Pattern, Inverted Pyramid, Java
Star Pattern Program, Pyramid pattern, Right Triangle Pattern, Star Pattern Program Star Pattern,
Triangle Pattern